Chrome 用 GM関数ラッパー
//Google Chrome用GM_*系ラッパー関数
function initGMWrapper() {
if ((typeof GM_getValue == 'undefined') || (GM_getValue('a', 'b') == undefined)) {
GM_addStyle = function(css) {
var style = document.createElement('style');
style.textContent = css;
document.getElementsByTagName('head')[0].appendChild(style);
}GM_deleteValue = function(name) {
localStorage.removeItem(LOCAL_STORAGE + "." + name);
}GM_getValue = function(name, defaultValue) {
var value = localStorage.getItem(LOCAL_STORAGE + "." + name);
if (!value)
return defaultValue;
var type = value[0];
value = value.substring(1);
switch (type) {
case 'b':
return value == 'true';
case 'n':
return Number(value);
default:
return value;
}
}GM_log = function(message) {
console.log(message);
}GM_registerMenuCommand = function(name, funk) {
//todo
}GM_setValue = function(name, value) {
value = (typeof value)[0] + value;
localStorage.setItem(LOCAL_STORAGE + "." + name, value);
}
GM_listValues = function() {
var res = new Array();
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
if (key.indexOf(LOCAL_STORAGE + ".", 0) == 0) {
res.push(key.replace(/^.*?\./, ""));
}
}
return res;
}
}
}