Converting Greasemonkey script to actual JS

Discussion in 'JavaScript' started by nullz0r, Feb 13, 2010.

  1. #1
    Hello everybody,
    I have this Greasemonkey script : http://userscripts.org/scripts/show/56715
    and I'd like to have it in my website as an actual JS, so people don't have to install Greasemonley but can still use it.

    The purpose of this script is to replace in a page each UploadJockey.com's links (which is a multi-uploader) by the real filehosts links.
    Could someone help me convert it into "actual" non-greasemonkey JS.
    The source code is available here : http://userscripts.org/scripts/review/56715

    Thanks !
     
    nullz0r, Feb 13, 2010 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    not gonna happen that easy - gm has its own XHR method which IS cross-domain (as its from the browser so security limitations don't apply)

    GM_xmlhttpRequest(); -> the script is using it.
     
    dimitar christoff, Feb 14, 2010 IP
  3. nullz0r

    nullz0r Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for you answer.
    So, is there any way to make cross-domain XHR with AJAX ?
    I found this : http://www.ajax-cross-domain.com and http://cross-domain-ajax.googlecode.com/svn/trunk/cdajax.js but can't get them to work...
     
    nullz0r, Feb 14, 2010 IP
  4. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #4
    you can easily use YQL to proxy the request though. for instance, consider this code i wrote a while back to do just that (through mootools)

    http://mootools.net/shell/aUgSz/

    of the ones you posted, http://www.ajax-cross-domain.com seems to be the proxy for the requests itself, the other one seems to be similar but would rely on you doing your own proxy. basically though, if you 'define' GM_xmlhttpRequest() { ... } to use either method, connect through YQL or your own proxy... and return data in a similar format - then it will work.

    yahoo's YQL api for that is:

    http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%20=%20%27http://fragged.org%27&format=xml (for instance, to fetch from fragged.org)
     
    dimitar christoff, Feb 14, 2010 IP