Is there any way to disable all other Java scripts except mine using Grease Monkey

I need help to get Grease Monkey with jQuery Script to run on a broken site.

I am trying to run the following GM Script, but there is a JS error on the page I want to work on and my JS is not executing.

// ==UserScript== // @name BILL INFO PAGE ALTER // @namespace http://jenkinslaw.org // @description Alter the web page in order to pretty print // @include http://www.legis.state.pa.us/cfdocs/billinfo/bill_history.cfm?* // @require http://code.jquery.com/jquery-1.4.2.min.js // ==/UserScript== */ (function() { //Make a copy of the bill table var bill_table = $('.main_table').clone(); //empty the whole lot $(body).empty(); //append the bill back to the dom. $(body).append(bill_table); }()); 

Thanks!

D

Progress:

I agree with @mkoryak, this is an impossible problem to solve with GM. So I drop it and use the Firefox extension instead (I hope it does not run into the same problem).

I will follow the example that I saw in another post here on the OS: How to use jQuery in a Firefox extension

I managed to get it to work, but with a slight modification in the example shown:

(As an aside, I used the Firefox Extension Wizard to quickly and easily get the basic structure for setting extensions).

 jQuery.noConflict(); (function($){ billinfo = new function(){}; billinfo.log = function(){ Firebug.Console.logFormatted(arguments,null,"log"); }; billinfo.run = function(doc,aEvent) { // Check for website if(!doc.location.href.match(/^http:\/\/(.*\.)?legis\.state\.pa\.us\/cfdocs\/billinfo\/bill_history\.cfm\?(.*)?$/i)) return; // Check if already loaded if(doc.getElementById("plugin-billinfo")) return; // Setup this.win = aEvent.target.defaultView.wrappedJSObject; this.doc = doc; //Make a copy of the bill table bill_table = $('.main_table', doc).clone(); //empty the whole lot $('body', doc).empty(); //append the bill back to the dom. $('body', doc).append(bill_table); }; // Bind Plugin var delay = function(aEvent){ var doc = aEvent.originalTarget; setTimeout(function(){ billinfo.run(doc,aEvent); },1); }; var load = function(){ gBrowser.addEventListener("DOMContentLoaded", delay, true); }; window.addEventListener("pageshow", load, false) })(jQuery); 
0
source share
2 answers

You cannot do this.

If there is a javascript error, your code (which is executed last) will never be executed.

I looked far and wide to solve this, but could not find it.

+2
source

GM and jQuery 1.4. * currently cannot coexist due to an error in the eventSupported function.
So you can use 1.3. * JQuery or include a modified version 1.4.2 directly in your script, such as suggested here .
Since you have chosen the expansion path, this has nothing to do with you, but I will post it for others with similar problems that may come across this in the future.

+1
source

Source: https://habr.com/ru/post/1307913/


All Articles