Cross Browser GM_api

in
Subscribe to Cross Browser GM_api 8 posts, 6 voices



lucideer Scriptwright
As the title says, this is here to discuss the assembly of cross browser functions to emulate the GM_functions. There are already a few scripts floating about that do this, so there's some code there to work with. However some of the solutions are not perfect, needing polish, and some others are simply deficient (completely un-doable to date). First off, I have only used IE7Pro once or twice. I know it has a PRO_api that is supposed to be similar but I don't know anything about it.



Rundown of the state of the api in other browsers:

GM_getValue, GM_setValue, GM_deleteValue, GM_listValues These require saving persistent data that can be accessed across different domains, but limited to the script that sets it. There are therefore two considerations in a cross-browser implementation:

(1) - storing cross-domain persistent data - IE8 supports the (now deprecated) HTML5 globalStorage for this, Safari has some kind of proprietary local database, Chrome has Gears, Opera has sweet f all unfortunately.
(2) - making the values stored accessible only by the script that set them. This is a huge security issue that seems quite difficult to implement.

GM_getResourceURL, GM_getResourceText I've never used either of these, so please correct me if I'm wrong, but they can simply be replaced with a url in which case the only "downside" is a slight increase in bandwidth.

GM_log Not really crucial.

unsafeWindow window

GM_addStyle very very easy

GM_registerMenuCommand I have some ideas for this one which I'll discuss later.

GM_openInTab window.open

GM_xmlhttpRequest This is the interesting one. I am only familiar with Opera, but while Opera has no method of direct cross-domain XHR, it does have various ways of sending, receiving and parsing data across domains. Opera supports HTML5 cross-document messaging, a very new technology that I'm not yet familiar with but I do know it's been used for this very purpose. I personally have used another method of reading script data from external scripts which works well for simple GET requests and is relatively simple.
 
Photodeus Scriptwright
FirefoxX11

I'm interested in having a simple API for making scripts in Opera that "just work".

Gears, Opera has sweet f all unfortunately.

This part I don't understand.

I am quite interested in porting some of my scripts to become Opera and Chrome compatible.

Some people use Firefox only so they can access the scripts I've made, but would prefer IE (those crazy fools) or Chrome otherwise.

 
lucideer Scriptwright
OperaWindows

This part I don't understand.

Google Chrome as the Google Gears plugin built in so it supports local persistent storage through that plugin. Opera only supports persistent storage via cookies unfortunately, so any scripts that rely very heavily on GM_getValue for persistent data, particularly between different domains, will likely not be portable. It's incredibly frustrating.

We've been asking the devs for HTML5 localStorage support for ages - their answer is that localStorage is a very unstable unfinished spec (much of Firefox's HTML5 localStorage is already deprecated for example - i.e. the WHATWG spec no longer contains the parts that Firefox supports because it's been changed so many times since) and the Opera devs don't want to waste time doing something they'll need to undo later, but any support for anything at all would be really nice to see. Particularly in userjavascript.

 
gabedibble Scriptwright
FirefoxWindows

I'm hoping we can get some common functionality soon so I can enable some features, like persistent data storage, currently disabled in my script for Opera & Chrome.

reStyling works across the board in 'google Enhanced BLACK' but I would like to provide full functionality when available.

Hopefully you don't mind me adding my script as I do test it for Opera (and Chrome) and maintain that support for certain users.

Best regards,
Gabriel D

 
Lil Devil Scriptwright
FirefoxWindows

I just found a GM_ emulation library written by TarquinWJ that can be found here. It adds functionality for GM_g/setValue, GM_registerMenuCommand, GM_xmlhttpRequest, GM_addStyle, and GM_log. There are limitations, of course, such as g/setValue uses cookies, and xmlhttpRequest is not cross-domain, but it should be acceptable in many cases. Using it, I was able to get most of my scripts working in Opera with only minor changes.

 
GIJoe Scriptwright
SeamonkeyMacintosh

The problem is that it uses cookies... that is send to the server at each request...

The better is to upgrade to Opera 10.50 and use localStorage.

Also, i use this for Cross Browser GM_api:
http://userscripts.org/topics/41177#posts-198077

 
ale5000 Scriptwright
MozillaWindows

Look at this and tell me what do you think => http://userscripts.org/scripts/show/88932

 
Lil Devil Scriptwright
FirefoxWindows

ale5000 wrote:
Look at this and tell me what do you think => http://userscripts.org/scripts/show/88932
This script was a great improvement over TarquinWJ's library. It still has a couple of issues, so I improved upon it. Let me know if there are any other improvements you'd like to see.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel