Falkon Develop
Cross-platform Qt-based web browser
bootstrap.js
Go to the documentation of this file.
1var GM = {
2 info: {
3 script: {
4 description: "",
5 excludes: [],
6 includes: [],
7 matches: [],
8 name: "",
9 namespace: "",
10 resources: {},
11 'run-at': "document-end",
12 version: ""
13 },
14 scriptMetaStr: "",
15 scriptHandler: "Falkon GreaseMonkey",
16 version: "4.0"
17 }
18};
19window.GM = GM;
20
21function GM_info() {
22 return GM.info;
23}
24
25function GM_xmlhttpRequest(/* object */ details) {
26 details.method = details.method.toUpperCase() || "GET";
27
28 if (!details.url) {
29 throw("GM_xmlhttpRequest requires an URL.");
30 }
31
32 // build XMLHttpRequest object
33 var oXhr = new XMLHttpRequest;
34 // run it
35 if("onreadystatechange" in details)
36 oXhr.onreadystatechange = function() { details.onreadystatechange(oXhr) };
37 if("onload" in details)
38 oXhr.onload = function() { details.onload(oXhr) };
39 if("onerror" in details)
40 oXhr.onerror = function() { details.onerror(oXhr) };
41
42 oXhr.open(details.method, details.url, true);
43
44 if("headers" in details)
45 for(var header in details.headers)
46 oXhr.setRequestHeader(header, details.headers[header]);
47
48 if("data" in details)
49 oXhr.send(details.data);
50 else
51 oXhr.send();
52}
53
54function GM_addStyle(/* string */ styles) {
55 var head = document.getElementsByTagName("head")[0];
56 if (head === undefined) {
57 document.onreadystatechange = function() {
58 if (document.readyState == "interactive") {
59 var oStyle = document.createElement("style");
60 oStyle.setAttribute("type", "text/css");
61 oStyle.appendChild(document.createTextNode(styles));
62 document.getElementsByTagName("head")[0].appendChild(oStyle);
63 }
64 }
65 }
66 else {
67 var oStyle = document.createElement("style");
68 oStyle.setAttribute("type", "text/css");
69 oStyle.appendChild(document.createTextNode(styles));
70 head.appendChild(oStyle);
71 }
72}
73
74function GM_log(log) {
75 if(console)
76 console.log(log);
77}
78
79function GM_openInTab(url) {
80 return window.open(url);
81}
82
83function GM_setClipboard(text) {
84 external.extra.greasemonkey.setClipboard(text);
85}
86
87// GM_registerMenuCommand not supported
88function GM_registerMenuCommand(caption, commandFunc, accessKey) { }
89
90// GM_getResourceUrl not supported
91function GM_getResourceUrl(resourceName) { }
92
93// GreaseMonkey 4.0 support
94GM.openInTab = GM_openInTab;
95GM.setClipboard = GM_setClipboard;
96GM.xmlhttpRequest = GM_xmlhttpRequest;
97
98// GM_getResourceUrl not supported
99GM.getResourceUrl = function(resourceName) {
100 return new Promise((resolve, reject) => {
101 reject();
102 });
103};