Strictly speaking, you cannot execute MySQL statements in Firefox, although you can in Chrome for the moment.
In Firefox you can create and use IndexedDB databases -- a more supported browser-DB approach (that is actually in the HTML5 spec). This might be enough, depending on your ultimate goal.
For full, traditional, DB support, you will have to write a web interface...
You can host such an interface on any machine using something like XAMPP. (Or use the language of your choice.)
Send your data from the Greasemonkey script to the web-app, using GM_xmlhttpRequest
, like so:
var myData = {strVar: 'Hiya!', intVar: 777, etc: 'et cetera'};
var DataForDB = JSON.stringify (myData);
GM_xmlhttpRequest ( {
method: "POST",
url: "http://localhost/YourDir/LogMyData.php",
data: DataForDB,
headers: {"Content-Type": "application/json"}
} )
A PHP webpage would extract the data like so:
$myData = json_decode($HTTP_RAW_POST_DATA);
print_r ($myData);
The web page then interacts with mySQL as you see fit, returning any desired values to the GM script.