Is it possible to store data across domains using a Greasemonkey script? I want to allow a Javascript object to be accessed from multiple websites that are using the same Greasemonkey script.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, that is one of the purposes of
GM_setvalue(), it stores data, per script, and across domains.Beware that the bog-standard
GM_setValue()is somewhat problematic. It can use lots of global resources or cause a script instance to crash.Here are some guidelines:
Do not use
GM_setValue()to store anything but strings. For anything else, use a serializer such as GM_SuperValue. Even innocent looking integers can cause the defaultGM_setValue()to crash.Rather than store lots of small variables, it may be better to wrap them in an object and store that with one of the serializers.
Finally note that
localStoragehas a specific meaning in javascript, andlocalStorageis domain specific.