/usr/share/xul-ext/greasemonkey/modules/miscapis.js is in xul-ext-greasemonkey 3.8-1~deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | var Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("chrome://greasemonkey-modules/content/third-party/getChromeWinForContentWin.js");
Cu.import('chrome://greasemonkey-modules/content/prefmanager.js');
Cu.import("chrome://greasemonkey-modules/content/util.js");
var EXPORTED_SYMBOLS = [
'GM_addStyle', 'GM_console', 'GM_Resources', 'GM_ScriptLogger'];
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
function GM_Resources(script) {
this.script = script;
this.stringBundle = Components
.classes["@mozilla.org/intl/stringbundle;1"]
.getService(Components.interfaces.nsIStringBundleService)
.createBundle("chrome://greasemonkey/locale/greasemonkey.properties");
}
GM_Resources.prototype.getResourceURL = function(aScript, name) {
return ['greasemonkey-script:', aScript.uuid, '/', name].join('');
};
GM_Resources.prototype.getResourceText = function(name) {
var dep = this._getDep(name);
if (dep.textContent !== undefined) return dep.textContent;
return GM_util.fileXhr(dep.file_url, "text/plain");
};
GM_Resources.prototype._getDep = function(name) {
var resources = this.script.resources;
for (var i = 0, resource; resource = resources[i]; i++) {
if (resource.name == name) {
return resource;
}
}
throw new Error(
this.stringBundle.GetStringFromName('error.missingResource')
.replace('%1', name)
);
};
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
function GM_ScriptLogger(script) {
var namespace = script.namespace;
if (namespace.substring(namespace.length - 1) != "/") {
namespace += "/";
}
this.prefix = [namespace, script.name, ": "].join("");
}
GM_ScriptLogger.prototype.consoleService = Components
.classes["@mozilla.org/consoleservice;1"]
.getService(Components.interfaces.nsIConsoleService);
GM_ScriptLogger.prototype.log = function(message) {
// https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIConsoleService#logStringMessage() - wstring / wide string
this.consoleService.logStringMessage((this.prefix + '\n' + message).replace(/\0/g, ''));
};
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
function GM_addStyle(doc, css) {
var head = doc.getElementsByTagName("head")[0];
if (head) {
var style = doc.createElement("style");
style.textContent = css;
style.type = "text/css";
head.appendChild(style);
return style;
}
return null;
}
// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
function GM_console(script) {
// based on http://www.getfirebug.com/firebug/firebugx.js
var names = [
"debug", "warn", "error", "info", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile",
"profileEnd"
];
for (var i=0, name; name=names[i]; i++) {
this[name] = function() {};
}
// Important to use this private variable so that user scripts can't make
// this call something else by redefining <this> or <logger>.
var logger = new GM_ScriptLogger(script);
this.log = function() {
logger.log(
Array.prototype.slice.apply(arguments).join("\n")
);
};
}
GM_console.prototype.log = function() {
};
|