Skip to content

Commit

Permalink
compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kynikos committed May 4, 2012
1 parent 991998c commit fa17547
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 0 deletions.
Expand Up @@ -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('&');
Expand Down
Expand Up @@ -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('&');
Expand Down
Expand Up @@ -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('&');
Expand Down
Expand Up @@ -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('&');
Expand Down

0 comments on commit fa17547

Please sign in to comment.