Skip to content
Browse files

#75: Support Opera

  • Loading branch information...
1 parent 614a8a5 commit 97a99e113b6be12f011d19882f971c3509c95246 @kynikos committed May 3, 2012
View
95 src/configurations/opera/WikiMonkey-archwikibot-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -326,25 +401,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
95 src/configurations/opera/WikiMonkey-archwikieditor-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -326,25 +401,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
95 src/configurations/opera/WikiMonkey-archwikipatrol-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -326,25 +401,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
95 src/configurations/opera/WikiMonkey-archwikipatrollite-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -326,25 +401,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
95 src/configurations/opera/WikiMonkey-bot-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -162,25 +237,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
95 src/configurations/opera/WikiMonkey-editor-opera.user.js
@@ -35,6 +35,81 @@
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
+
var WM = new function () {
var queryString = (function () {
var qa = location.search.substr(1).split('&');
@@ -162,25 +237,29 @@ WM.Bot = new function () {
selectLists.id = 'WikiMonkeyBot-ListSelect';
for (var l in lists) {
- option = document.createElement('option');
- option.innerHTML = lists[l][2];
- selectLists.appendChild(option);
+ if (lists[l][0]) {
+ option = document.createElement('option');
+ option.innerHTML = lists[l][2];
+ selectLists.appendChild(option);
+
+ if (!WM.Bot.selections.list.current) {
+ // [1] Note that this is also executed onchange, see [2]
+ // Don't use "this.selections"
+ WM.Bot.selections.list.current = lists[l];
+ }
+ }
}
selectLists.addEventListener("change", (function (lss) {
return function () {
var select = document.getElementById('WikiMonkeyBot-ListSelect');
var id = select.selectedIndex;
WM.Bot.selections.list.previous = WM.Bot.selections.list.current;
- // [1] Note that this must also be executed immediately, see [2]
+ // [2] Note that this must also be executed immediately, see [1]
WM.Bot.selections.list.current = lss[id];
}
})(lists), false);
- // [2] Note that this is also executed onchange, see [1]
- // Don't use "this.selections"
- WM.Bot.selections.list.current = lists[0];
-
return selectLists;
};
View
74 src/files/GmApiEmulation.js
@@ -0,0 +1,74 @@
+if (!GM_setValue || !GM_getValue || !GM_listValues || !GM_deleteValue) {
+ var setWikiMonkeyGmApiEmulationCookie = function (value) {
+ var name = "WikiMonkeyGmApiValuesEmulation";
+
+ var expireDate = new Date();
+ expireDate.setTime(expireDate.getTime() + (3110400000)); // 36 days
+ var expires = ";expires=" + expireDate.toUTCString();
+
+ var path = ";path=/";
+
+ document.cookie = name + "=" + escape(value) + expires + path;
+ };
+
+ var getWikiMonkeyGmApiEmulationCookie = function () {
+ if (document.cookie.length > 0) {
+ var cookieArray = document.cookie.split(';');
+ var regExp = /^ *WikiMonkeyGmApiValuesEmulation\=(.+)$/;
+ for (var i in cookieArray) {
+ var match = regExp.exec(cookieArray[i]);
+ if (match) {
+ return unescape(match[1]);
+ }
+ }
+ }
+ return null;
+ };
+
+ var GM_setValue = function (name, value) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ valueDict[name] = value;
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return value;
+ };
+
+ var GM_getValue = function (name, defaultValue) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : undefined;
+ return (valueDict) ? valueDict[name] : defaultValue;
+ };
+
+ var GM_listValues = function () {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ if (valueString) {
+ var valueDict = JSON.parse(valueString);
+ var keys = [];
+ for (var key in valueDict) {
+ keys.push(key);
+ }
+ return keys;
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ var GM_deleteValue = function (name) {
+ var valueString = getWikiMonkeyGmApiEmulationCookie();
+ var valueDict = (valueString) ? JSON.parse(valueString) : {};
+ delete valueDict[name];
+ setWikiMonkeyGmApiEmulationCookie(JSON.stringify(valueDict));
+ return undefined;
+ };
+}
+
+if (!GM_addStyle) {
+ var GM_addStyle = function (css) {
+ var head = document.getElementsByTagName('head')[0];
+ var style = document.createElement('style');
+ style.setAttribute('type', 'text/css');
+ style.innerHTML = css;
+ head.appendChild(style);
+ };
+}
View
8 src/files/opera.py
@@ -7,6 +7,7 @@
CFG_PATH = os.path.join(SRC_PATH, "configurations")
OPERA_PATH = os.path.join(CFG_PATH, "opera")
MAIN_SCRIPT = os.path.join(SRC_PATH, "WikiMonkey.js")
+GM_API_EMULATION = "GmApiEmulation.js"
def read_script(s):
@@ -23,6 +24,11 @@ def get_licence():
return "\n" + match.group(1) + "\n"
+def get_GM_API_emulation():
+ with open(GM_API_EMULATION, 'r') as s:
+ return "\n" + s.read()
+
+
def write_opera_configuration(f, g):
functions = ""
header = True
@@ -34,7 +40,7 @@ def write_opera_configuration(f, g):
functions += read_script(s)
elif line[:18] == "// ==/UserScript==":
header = False
- g.write(line + get_licence() + functions)
+ g.write(line + get_licence() + get_GM_API_emulation() + functions)
else:
g.write(line)

0 comments on commit 97a99e1

Please sign in to comment.
Something went wrong with that request. Please try again.