0

Trying to remove a certain script from being loaded via greasemonkey: (so removing bascially removing the url and url part.)

....,"url":"https://this.site.com/xc/sample/dir?locale=en-us"},...

Something like this?

var x = document.body.innerHTML;
x = x.match(/https\:\/\/this\.site\.com\/xc\/sample\/dir.*\"\/)[0];
x = x.replace(/something…/, “”);
alert(x);
Janet D
  • 23
  • 3

1 Answers1

0

You can try to intercept the url call (looks like it is ajax) with the following:

XMLHttpRequest.prototype.realOpen = XMLHttpRequest.prototype.open;

var myOpen = function(method, url, async, user, password) {
    //do whatever mucking around you want here, e.g.
    //changing the onload callback to your own version

    if (url == "the url you want to intercept and stop")
    {
       alert("The deed is done!");
    }
    else
    {
       //call original
       this.realOpen (method, url, async, user, password);
    }
}  


//ensure all XMLHttpRequests use our custom open method
XMLHttpRequest.prototype.open = myOpen ;

The code above is inspired by this SO answer: How can I intercept XMLHttpRequests from a Greasemonkey script?

Eriks Klotins
  • 4,042
  • 1
  • 12
  • 26
  • So adding (url == "https://this.site.com/xc/sample/dir?locale=en-us") is enough here? – Janet D Feb 24 '20 at 22:26
  • We do not know the specifics of the site you are trying to modify. The code itself should work, given that you replace the placeholder with the right URL. Try it out and update your question if needed. – Eriks Klotins Feb 25 '20 at 04:47