有没有办法禁用所有其他的Java脚本,而不是我自己的油猴 [英] Is there a way to disable all other Java Scripts other than my own with Grease Monkey

查看:302
本文介绍了有没有办法禁用所有其他的Java脚本,而不是我自己的油猴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我试图让下面的GM脚本运行,但是我希望它的工作有一个JS错误,我的JS没有得到执行。

  // == UserScript == 
// @name BILL INFO PAGE ALTER
// @namespace http://jenkinslaw.org
// @description改变网页以便打印
// @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(){

//制作帐单表
var bill_table = $('。main_table')。clone();

//清空整个
$(body).empty();

//将账单追加到dom。
$(body).append(bill_table);

}());

谢谢!

D



进度:



我同意@mkoryak这是用GM解决的一个不可能的问题。所以我放弃它,并使用Firefox扩展,而不是(希望它不会遇到同样的问题)。

我会按照我看到在另一篇文章在操作系统上:
如何在Firefox扩展中使用jQuery



我可以正常工作,但是从示例中稍作修改:

(另外,我使用了 Firefox扩展向导即可轻松快速地获取扩展设置的基本框架)。

  jQuery .noConflict(); 
(function($){

billinfo = new function(){};
billinfo.log = function(){Firebug.Console.logFormatted(arguments,null, (doc,aEvent){

//检查网站
if(!doc.location.href.match(/ ^ HTTP:?\ / \ /(.* \)legis\.state\.pa\.us\ / cfdocs\ / billinfo\ / bill_history\.cfm\( *)?$ / i))return;

//检查是否已经加载
if(doc.getElementById(plugin-billinfo))return;

//安装
this.win = aEvent.target.defaultView.wrappedJSObject;
this.doc = doc;

//制作账单表
bill_table = $('。main_table',doc).clone();

//清空整个
$('body',doc).empty();

//将账单追加到dom
$('body',doc).append(bill_table);
};

/ / Bind插件
var delay = function(aEvent){var doc = aEvent.originalTarget; setTimeout(fun ction(){billinfo.run(doc,aEvent);},1);};
var load = function(){gBrowser.addEventListener(DOMContentLoaded,delay,true); };
window.addEventListener(pageshow,load,false)
})(jQuery);


解决方案

你无法做到。



如果存在javascript错误,您的代码(最后执行的代码)永远不会执行。

看起来远远超过这个解决方案,但从来没有找到它。


I need help getting a Grease Monkey with JQuery Script to run on a broken site.

I'm trying to get the following GM script to run, but the page I want it to work on has a JS error and my JS does not get executed.

// ==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'm dropping it and using a Firefox extension instead (hopefully it wont run into the same issue).

I'll be following the example I saw on another post here on OS: How to use jQuery in Firefox Extension

I was able to get it working but with a slight modification from the example shown:

(As an aside, I used the Firefox Extension Wizard to get a basic framework of the extension set-up easily and quickly).

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);

解决方案

You cant do it.

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

I have looked far and wide for a solution for this, but was never able to find it.

这篇关于有没有办法禁用所有其他的Java脚本,而不是我自己的油猴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆