Requests for scripts to be adapted

in
Subscribe to Requests for scripts to be adapted 21 posts, 6 voices



lucideer Scriptwright
I'm opening this thread with the intent of posting a list of really really great scripts on uso that don't currently qualify for inclusion in this group (as they're not cross-browser), but that members of this group could hopefully work on adapting to include them.



I'll start the ball rolling with something I think looks like a potentially great project. GM_config

Changes to be made:
  1. default is an ECMAScript reserved keyword but this script seems to make use of it in a good few places, so this could be replaced with say... defaultValue to make it work in browsers supporting ECMAScript (i.e. Opera).
  2. Firefox is the only browser to have adopted the ECMAScript4XML (E4X) standard sofar so E4X multiline strings (used in this script) need replacing with normal strings to make it cross-browser
  3. This obviously uses GM_getValue(). The GM_api is of course the Greasemonkey api so a cross-browser alternative could be put in
I've tried doing the first two of those, and they seem to work OK. The last is of course the great obstacle...
 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

I'm actually very interested in modifying GM_config to be cross-browser. Sorry I've been so slow to get around to it. I've been preoccupied.
1. I found out default causes errors when adapting one of my scripts for Safari 4 with Greasekit. Instead of whatever.default we can use whatever['default']
2. Yeah... I didn't put that in script, but it'll be replaced with strings.
3. Safari 4 supports databases: http://webkit.org/demos/sticky-notes/index.html and Google Chrome has gears. So I just need to figure out how to implement those two. Could you help me with Opera? I understand it supports localStorage?

 
barrold User
OperaWindows

I'd really like to see an Opera version of one of the scripts that integrates Google Reader into Gmail. There are a handful of them around, but this is seemingly the most interesting: http://userscripts.org/topics/18054?page=1#post...

I posted in a thread for that one a while ago, but noone there seems too interested. Anyone here willing to give it a stab?

 
barrold User
OperaWindows

Another thought: I seem to have to reload gmail once every time i load it before the auto signin works.

I have the cookie setting on "accept from site you have visited," and to delete new. I think this is the problem, but I can't find a solution online. Not sure if anyone else has this problem?

One solution would seem to be a script that automatically reloads Gmail the first time it loads (that is, if javascript can do that kind of thing). Thanks.

 
Coldframe User
FirefoxWindows

I'd love to see Travian3 Beyond - ML&CN
http://userscripts.org/scripts/show/28129

be adapted..

 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

Coldframe wrote:
I'd love to see Travian3 Beyond - ML&CN

I gave my advice to the author.

 
1nfected Scriptwright
FirefoxWindows
Any suggestions how this could be made Opera compatible.
It gives a 'return must be within a function' error right now & pushing it inside the anonymous function doesn't help.

Im testing on Opera 10.51 btw.
 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

1nfected wrote:
Any suggestions how this could be made Opera compatible.
For starters you're using localStorage improperly. Here's a proper example(mostly taken from GM_config which is now cross-browser) of implementing cross-browser GM-api replacement functions:
var isGM: typeof GM_getValue != 'undefined' && 
          typeof GM_getValue('a', 'b') != 'undefined',
    log: (this.isGM) ? GM_log : (window.opera ? opera.postError : console.log),
    setValue = isGM ? GM_setValue : 
                   function (name, value) {
                       return localStorage.setItem(name, value);
                   },
    getValue = isGM ? GM_getValue : 
                   function(name, def){
                       var s = localStorage.getItem(name);
                       return s === null ? def : s
                   };

Using these you can properly test for whether you're in Greasemonkey(isGM), log messages in the console(log()), and set and get persistent values(setValue()/getValue()). For more information, I also wrote a huge ass guide recently that features a section on making your script cross-browser friendly.

 
1nfected Scriptwright
FirefoxWindows

cool, will check it out and post back.
thanks for the info Smile

 
GIJoe Scriptwright
SeamonkeyMacintosh

@sizzlemctwizzle: Don't forget that localStorage is "string" only...
So setValue("name",1); return getValue("name",0)+1; is 11 instead of 2.

My cross browser GM Api is here: http://userscripts.org/topics/41177#posts-198077

 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

GIJoe wrote:
@sizzlemctwizzle: Don't forget that localStorage is "string" only...
Yeah true but you just need to make sure to cast the string to a number like setValue("name",1); return +getValue("name",0)+1 which will return 2. You could make this conversion automatic my modifying the getValue function.
var getValue = isGM ? GM_getValue : 
                   function(name, def){
                       var s = localStorage.getItem(name);
                       return s === null ? def : isNaN(s) ? s : +s;             
                   };

 
1nfected Scriptwright
FirefoxWindows
Well, i've been trying to write cross-browser compatible code. Thanks once again sizzlemctwizzle for that piece of code.
I've used it (and also GIJoe's cross-browser GM Api) and now my script is semi compatible with Opera.
Everything works except for adding the menu part. I get the following error:
guser error : TypeError: Cannot convert 'document.getElementById("guser")' to object
I get this with both the methods (urs and GIJoe's). I've upped the code at Pastebin.
Any way i can overcome this error?

@GIJoe: I came across this discussion topic in your Youtube script & tried the solution mentioned there as well, but to no avail.
 
GIJoe Scriptwright
SeamonkeyMacintosh

Is document.getElementById("guser")==null ?

 
1nfected Scriptwright
FirefoxWindows
GIJoe wrote:
Is document.getElementById("guser")==null ?
Yeah, it is infact null :s
Could that be because of security restrictions on iframe?
 
1nfected Scriptwright
FirefoxWindows

bumpy...

 
sizzlemctwizzle Scriptwright
FirefoxMacintosh

1nfected wrote:
Yeah, it is infact null :s
The only reason getElementId would return null is if that element is not on the page. Either way it has nothing to do with cross-browser compatibility.

 
1nfected Scriptwright
FirefoxWindows

sizzlemctwizzle wrote:
The only reason getElementId would return null is if that element is not on the page. Either way it has nothing to do with cross-browser compatibility.

I'm quite certain the element exists. Can see it in dragonfly using the Inspect Element option.
And the same code works in Firefox & Chrome.

 
GIJoe Scriptwright
SeamonkeyMacintosh

Try looping until it is not null...

 
1nfected Scriptwright
FirefoxWindows

GIJoe wrote:
Try looping until it is not null...
Already tried that & a whole lot other ways...
Actually, i was wrong earlier, var guser = gmail.getElementById("guser"); does not return null.
The problem lies in this line guser = guser.firstChild; (ie when i'm trying to access the firstChild property, even children[0] doesn't help) The browser hangs when it reaches this line :s

 
GIJoe Scriptwright
SeamonkeyMacintosh

check guser.childNodes.length or guser.innerHTML

 
1nfected Scriptwright
FirefoxWindows
GIJoe wrote: check guser.childNodes.length or guser.innerHTML
let me try that, but i'm guessing that would make the browser hang, since its again accessing a property of guser. i'll report back after giving it a try though.

edit: well, i was able to access both the properties you mentioned & they return the correct values.
but as soon as i try to access firstChild property, the browser hangs! and i also noticed, opera in such situations does not log the last few msgs either. for eg in the following code:
var guser = gmail.getElementById("guser");
if(guser == null) { log("guser is null"); return; }
else {
log("found guser!");
guser = guser.firstChild;
}
i wouldn't see any msg in the console. but if i put an alert statement after log("found guser!"); i could see the msg.
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