加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
speedupErrorConsole.uc.js 2.71 KB
一键复制 编辑 原始数据 按行查看 历史
alice0775 提交于 2013-05-02 00:27 . test
// ==UserScript==
// @name speedupErrorConsole.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description sppedup Error Console (hide long source code) Bug 840451
// @include chrome://global/content/console.xul
// @include chrome://console2/content/console2.xul
// @include main
// @compatibility Firefox 10+
// @author Alice0775
// @version 2013/05/30 11:30
// @version 2013/02/11 12:30
// ==/UserScript==
(function() {
function applyPatch() {
if (!document.getElementById('ConsoleBox'))
return;
var func = document.getElementById('ConsoleBox').appendError.toString();
if (/\.indexOf\("CSS"\)/.test(func))
return;
if(/aObject/.test(func)) {
func = func.replace(
'row.setAttribute("code", truncatedLineObj.string);',
'if (!aObject.category || aObject.category.indexOf("CSS") < 0 || aObject.columnNumber < 120) {$&'
).replace(
'row.mSourceLine = sourceLine;',
'$&}else{}'
).replace(
'if (aObject.columnNumber) {',
'$&if (!aObject.category || aObject.category.indexOf("CSS") < 0 || aObject.columnNumber < 120) {'
).replace(
'row.setAttribute("errorCaret", " ");',
'} else {row.setAttribute("code", "Column: " + aObject.columnNumber || 0);row.setAttribute("hideCaret", "true");}'
);
document.getElementById('ConsoleBox').appendError = new Function(
func.match(/\(([^)]*)/)[1],
func.replace(/[^{]*\{/, '').replace(/}\s*$/, '')
);
} else {
func = func.replace(
/if \(aMessage\.sourceLine\)[\s\t\r]+\{/,
'$& if (!aMessage.category || aMessage.category.indexOf("CSS") < 0 || aMessage.columnNumber < 120){'
).replace(
'row.setAttribute("errorDots", this.repeatChar(" ", aMessage.columnNumber));',
'$&} else {row.setAttribute("code", "Column: " + aMessage.columnNumber || 0);}'
);
document.getElementById('ConsoleBox').appendError = new Function(
func.match(/\(([^)]*)/)[1],
func.replace(/[^{]*\{/, '').replace(/}\s*$/, '')
);
}
}
if (location.href == "chrome://browser/content/browser.xul") {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var enumerator = wm.getEnumerator(null);
while(enumerator.hasMoreElements()) {
var win = enumerator.getNext();
// win is [Object ChromeWindow] (just like window), do something with it
if (win.location.href == "chrome://global/content/console.xul" ||
win.location.href == "chrome://console2/content/console2.xul")
applyPatch();
break;
}
} else {
applyPatch();
}
})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化