blob: 5c18929e040e250075450eaf6f40715f95d62001 (
plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adblock Plus Errors</title>
<style type="text/css">
.warning, .error
{
border: 1px dashed black;
margin: 5px;
padding: 2px;
white-space: pre-wrap;
}
.error
{
background-color: #fff0f0;
}
.warning
{
background-color: #ffffe0;
}
button
{
float: right;
}
</style>
</head>
<body>
<button onclick="window.location.reload();">Refresh</button>
<button onclick="clearErrors();">Clear errors</button>
<script type="application/x-javascript;version=1.7">
let id = null;
try {
let {addonVersion, addonID} = require("info");
let text = "You are running Adblock Plus " + addonVersion;
text += ".";
document.write("<p>" + text + "</p>");
id = addonID.replace(/[\{\}]/g, "");
} catch (e) {}
// See https://bugzilla.mozilla.org/show_bug.cgi?id=664695 - starting with
// Gecko 19 this function returns the result, before that it wrote to a
// parameter.
let outparam = {};
let messages = Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.getMessageArray(outparam, {});
messages = messages || outparam.value || [];
messages = messages.filter(function(message)
{
return (message instanceof Components.interfaces.nsIScriptError &&
!/^https?:/i.test(message.sourceName) &&
(/adblock/i.test(message.errorMessage) || /adblock/i.test(message.sourceName) ||
id && (message.errorMessage.indexOf(id) >= 0 || message.sourceName && message.sourceName.indexOf(id) >= 0)));
});
if (messages.length)
{
document.write("<p>Errors related to Adblock Plus:</p>");
for each (let message in messages)
{
let type = (message.flags & Components.interfaces.nsIScriptError.warningFlag ? "warning" : "error");
let html = "<b>" + (type == "warning" ? "Warning:" : "Error:") + "</b><br>";
html += encodeHTML(message.errorMessage) + "<br><br>";
if (message.sourceLine)
html += "Source line: " + encodeHTML(message.sourceLine) + "<br>";
if (message.sourceName)
html += "Location: " + encodeHTML(message.sourceName) + " line " + message.lineNumber + "<br>";
html = html.replace(/(<br>)+$/, "");
document.write("<div class='" + type + "'>" +
html +
"</div>");
}
}
else
{
document.write("<p>No errors found.</p>");
}
function require(module)
{
let {Services} = Components.utils.import("resource://gre/modules/Services.jsm");
let result = {};
result.wrappedJSObject = result;
Services.obs.notifyObservers(result, "adblockplus-require", module);
return result.exports;
}
function encodeHTML(string)
{
return string.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
}
function clearErrors()
{
Components.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService)
.reset();
window.location.reload();
}
</script>
</body>
</html>
|