forked from ywzhaiqi/userChromeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
speedupErrorConsole.uc.js
69 lines (67 loc) · 2.69 KB
/
speedupErrorConsole.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// ==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 21+
// @author Alice0775
// @version 2013/02/15 18:00 typo
// @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(
'if (aObject.sourceLine) {',
'$&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();
}
})();