I am trying to set data in a long-term storage in a GreaseMonkey script, except that GM_setValue () seems to fail:
$("a#linkid").click(function() { GM_setValue("foo", 123); // doesn't work, but does not generate error }); GM_setValue("bar", 123); // works properly, value is set
I think this is a special Greasemonkey security issue. See 0.7.20080121.0 compatibility . GM does not allow user pages to access GreaseMonkey APIs and what you do there (you register a click handler with jQuery running in a user context). A workaround is also listed on this page.
...
, ...
function gmGet(name) { var theValue = GM_getValue(name); return theValue; } function gmSet(name, valuee) { GM_setValue(name, valuee); } $("a#linkid").click(function(){ //setValue gmSet("foo", 123); //getValue gmGet("foo"); });
You can use this solution.
$("a#linkid").click(function() { //setValue setTimeout(GM_setValue("foo", 123),0); //getValue setTimeout(GM_getValue("foo"),0); });
Source: https://habr.com/ru/post/1708299/More articles:Использование точек с запятой в выражениях Oracle SQL - performanceGet a list of selected items in javascript - javascriptBacklight J2ME - mobileHow long does it take to become proficient in Oracle given SQL Server - oracleRandom Java VM crashes in ConcurrentGCThread - javaTrying to run perl scripts with fast-cgi and lighttpd, but the files just load - perlHow to save full state page in wpf navigation application - wpfWhy should I get GPF in DLLMain when running as a limited user? - c ++How to bounce a point from a line? - c ++Winsock Error Code 10014 - c ++All Articles