GreaseMonkey's new syntax style broke my script.

Post Reply
hitmanex
Posts: 3
Joined: 17.11.17 09:02:28

GreaseMonkey's new syntax style broke my script.

Post by hitmanex » 17.11.17 09:06:08

Before I was sending chrome users to tampermonkey and firefox users to Greasemonkey. With the recent firefox update and 4.0 greasemonkey change there are very drastic differences in the syntax and my script no longer works on firefox. With tampermonkey for firefox it works fine.

My question is are you planning to adopt these same changes (ie instead of GM_ X its GM.X) now and who decides on the syntax of userscripts?

I will use tampermonkey for everything now to have cross compatibility between browsers

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: GreaseMonkey's new syntax style broke my script.

Post by derjanb » 17.11.17 10:14:13

Tampermonkey Chrome Beta and Tampermonkey Firefox already support the GM.x API. :)
ImageIf you like what I'm doing, please consider a donation here. Image

hitmanex
Posts: 3
Joined: 17.11.17 09:02:28

Re: GreaseMonkey's new syntax style broke my script.

Post by hitmanex » 18.11.17 08:22:22

can you tell me how to fix this so it works on the new syntax?

Code: Select all

function checkReq() {
    var list = document.getElementById("gkpluginsExtListReq");
    if (list == null) {
        return;
    }
    list.title = "ready";
    if (list.childNodes.length > 0) {
        var curReq = list.firstChild;
        if (typeof curReq.innerHTML == "undefined") {
            list.removeChild(curReq);
            return;
        }
        var obj = JSON.parse(atob(curReq.innerHTML));
        obj.onload = obj.onerror = obj.onabor = function(response) {
            var txtout = document.createElement("textarea");
            txtout.id = obj.extreqid;
            txtout.style.display = "none";
            var Hfres = response.status + " " + response.statusText + "\r\n" + response.responseHeaders;
            if (response.finalUrl) {
                Hfres += "FinalLocation: " + response.finalUrl + "\r\n";
            }
            if (obj.returndtaescape) {
                txtout.value = escape(Hfres + "\r\n" + response.responseText);
            } else if (obj.returndtab64) {
                txtout.value = btoa(Hfres + "\r\n" + response.responseText);
            } else {
                txtout.value = Hfres + "\r\n" + response.responseText;
            }
            document.body.appendChild(txtout);
        };
        GM_xmlhttpRequest(obj);
        list.removeChild(curReq);
    }
}
setInterval(checkReq, 100);

how do i update this for the new syntax? or will it be backward compatible...

hitmanex
Posts: 3
Joined: 17.11.17 09:02:28

Re: GreaseMonkey's new syntax style broke my script.

Post by hitmanex » 20.11.17 13:03:39

derjanb wrote:
17.11.17 10:14:13
Tampermonkey Chrome Beta and Tampermonkey Firefox already support the GM.x API. :)
will scripts be backward compatible or not with tampermonkey?

will scripts that work now continue to work with your future updates?

User avatar
derjanb
Site Admin
Posts: 2383
Joined: 20.01.06 02:16:15
Contact:

Re: GreaseMonkey's new syntax style broke my script.

Post by derjanb » 20.11.17 13:06:06

hitmanex wrote:
20.11.17 13:03:39
will scripts be backward compatible or not with tampermonkey?

will scripts that work now continue to work with your future updates?

The "old" GM_x API will not be removed because it's more powerful due to its synchronous nature.
ImageIf you like what I'm doing, please consider a donation here. Image

Post Reply