File indexing completed on 2025-01-05 04:35:04

0001 var GM = {
0002     info: {
0003         script: {
0004             description: "",
0005             excludes: [],
0006             includes: [],
0007             matches: [],
0008             name: "",
0009             namespace: "",
0010             resources: {},
0011             'run-at': "document-end",
0012             version: ""
0013         },
0014         scriptMetaStr: "",
0015         scriptHandler: "Falkon GreaseMonkey",
0016         version: "4.0"
0017     }
0018 };
0019 window.GM = GM;
0020 
0021 function GM_info() {
0022     return GM.info;
0023 }
0024 
0025 function GM_xmlhttpRequest(/* object */ details) {
0026     details.method = details.method.toUpperCase() || "GET";
0027 
0028     if (!details.url) {
0029         throw("GM_xmlhttpRequest requires an URL.");
0030     }
0031 
0032     // build XMLHttpRequest object
0033     var oXhr = new XMLHttpRequest;
0034     // run it
0035     if("onreadystatechange" in details)
0036         oXhr.onreadystatechange = function() { details.onreadystatechange(oXhr) };
0037     if("onload" in details)
0038         oXhr.onload = function() { details.onload(oXhr) };
0039     if("onerror" in details)
0040         oXhr.onerror = function() { details.onerror(oXhr) };
0041 
0042     oXhr.open(details.method, details.url, true);
0043 
0044     if("headers" in details)
0045         for(var header in details.headers)
0046             oXhr.setRequestHeader(header, details.headers[header]);
0047 
0048     if("data" in details)
0049         oXhr.send(details.data);
0050     else
0051         oXhr.send();
0052 }
0053 
0054 function GM_addStyle(/* string */ styles) {
0055     var head = document.getElementsByTagName("head")[0];
0056     if (head === undefined) {
0057         document.onreadystatechange = function() {
0058             if (document.readyState == "interactive") {
0059                 var oStyle = document.createElement("style");
0060                 oStyle.setAttribute("type", "text/css");
0061                 oStyle.appendChild(document.createTextNode(styles));
0062                 document.getElementsByTagName("head")[0].appendChild(oStyle);
0063             }
0064         }
0065     }
0066     else {
0067         var oStyle = document.createElement("style");
0068         oStyle.setAttribute("type", "text/css");
0069         oStyle.appendChild(document.createTextNode(styles));
0070         head.appendChild(oStyle);
0071     }
0072 }
0073 
0074 function GM_log(log) {
0075     if(console)
0076         console.log(log);
0077 }
0078 
0079 function GM_openInTab(url) {
0080     return window.open(url);
0081 }
0082 
0083 function GM_setClipboard(text) {
0084     external.extra.greasemonkey.setClipboard(text);
0085 }
0086 
0087 // GM_registerMenuCommand not supported
0088 function GM_registerMenuCommand(caption, commandFunc, accessKey) { }
0089 
0090 // GM_getResourceUrl not supported
0091 function GM_getResourceUrl(resourceName) { }
0092 
0093 // GreaseMonkey 4.0 support
0094 GM.openInTab = GM_openInTab;
0095 GM.setClipboard = GM_setClipboard;
0096 GM.xmlhttpRequest = GM_xmlhttpRequest;
0097 
0098 // GM_getResourceUrl not supported
0099 GM.getResourceUrl = function(resourceName) {
0100     return new Promise((resolve, reject) => {
0101         reject();
0102     });
0103 };