Created
August 11, 2010 18:14
-
-
Save azu/519432 to your computer and use it in GitHub Desktop.
Fast look up JP and EN修正
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fast look up JP and EN | |
// @namespace http://d.hatena.ne.jp/jimo1001/ | |
// @description Fast look up Japanese and English character strings. | |
// @include * | |
// ==/UserScript== | |
var VERSION = "2009.03.16"; | |
var SITEINFO_IMPORT_URLS = | |
[ | |
'http://wedata.net/databases/FluJE/items.json', | |
]; | |
//----------------------------------------------------------------------------- | |
// SPACE ALC(英辞郎 on the WEB)はコメントを外せば利用できますが、『英辞郎 on the Web』の利用規約に違反しますので自己責任で行ってください. | |
//----------------------------------------------------------------------------- | |
var LOCAL_SITEINFO = | |
[ | |
// { | |
// name: 'SPACE ALC(英辞郎)', | |
// url: 'http://eow.alc.co.jp/[context]/', | |
// icon: 'data:image/gif;base64,R0lGODlhEAAQALMAABQSFI+Qj8/Pz1FRUbGxsefp53Nzc6KjouDf4GNkY769vvz+/ICCgCQmJJmYmVxaXCH5BAAAAAAALAAAAAAQABAAAwRocElZThqGzC1Pe4cgOE/ALUx2IJtjbASzEIPCObL0SuyZSAHBiUM4oIYcRFCzKfQmhQDhYTAkEg+AI7l9ChJCjsI2YTAKw62EAEYW1IgBEhheOBLoJOMpUTwYBCIHDGpDAgcBDgp5ExEAOw==', | |
// xpath: '(id("searchWord")/strong | id("itemsNumber") | id("resultList")//ul//li[position()<4])', | |
// NGxpath: 'id("resultArea")//ul/div/ul', | |
// lang: 'both', | |
// type: 'dictionary', | |
// enc: 'UTF-8' | |
// }, | |
] | |
var SITEINFO = []; | |
//=== Default settings === | |
var DefaultSettings = function() { | |
var s = { | |
ver: VERSION, | |
shortcutkey: { | |
navi_toggle: 'A-y', // show toggle(open/close) navi | |
close_all: 'ESC', // close all element | |
QL_run: 'y', // Run quick Look up | |
site: [], | |
}, | |
remove_result_all: true, | |
enable_wheel_button: true, | |
enable_modifier_key: true, // push modifier key when select character strings. | |
modifier_key: 'altKey', // modifier key for selection. | |
effect : true, | |
lookup: { // word, search | |
ja: [], // default site of input japanese strings | |
en: [], // default site of input english strings | |
ja_type: 'dictionary', | |
en_type: 'dictionary', | |
}, | |
translation: { // for select text | |
JtoE: true, // translate Japanese to English | |
ja_chars: '10', // translate Japanese more than this number of characters | |
EtoJ: true, // translate English to Japanese | |
en_words: '3', // translate Enlish more than this number of words | |
ja: [], | |
en: [], | |
} | |
} | |
return s; | |
} | |
//=== images === | |
var IMAGES = { | |
close: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAXCAYAAAD6FjQuAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAewQAAHsEBw2lUUwAAAAd0SU1FB9gBFxEPCSG3H1gAAAEXSURBVEjH7ZQxioQwFIb/jELA3trWI2yTC2gnpJrFwwlTCyk8g0fwEBZWivBithCDo7O7MpBU80PQPPPzveQ9w9I0NXCsrusghEC4LAsAwJiVyRh7adh/N8ac1r2KHRUSEXwp1Fr7hx2PaX+kWZYBAJqmsWvzPD/Fjv5jWW5EBCKC1hpa69M7EUEpZaFEZEFKKfzl3+YWHMex2Rd4n9U+O2MMiqKwsbquf22Uo6/v+7Ub322Qd3y3aZpwZUgpAQBVVQEApJS46rWwKxmVZfkE2p5b/KpYFEXOb5BxHNeaBUHg7z/zAeOcr7BhGMA5xzzPzkBJkgBAGwohWgBfjjfXAvhmDw+1um+tf4c/Pd01D4e7+uijf/UDzMDkaVlBIbwAAAAASUVORK5CYII=', | |
close_focused: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAXCAYAAAD6FjQuAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAewQAAHsEBw2lUUwAAAAd0SU1FB9gBFxEOJH1zcmwAAAI6SURBVEjH7ZWxbhQxEIa/sb23iU4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7LYZ5nAFQVAGPM7kI4V9UNb+9tIzaOY7pk0zSlF1vXtK40rOmoxvX+cr+2xsVt6Cp0t/dBYglD7jXJ+r6PEsuyjM6rqvoqZkmITzJr47p1XcddW/u7WJZlaZKJSDKxNs/zous6RIRhGE4REhGM9/4JvIAWKLhx48Zf4w2OIF4eoa/2XgAAAABJRU5ErkJggg==', | |
minimize_focused: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAXCAYAAAD6FjQuAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAewQAAHsEBw2lUUwAAAAd0SU1FB9gBFxEWDMrdQs8AAAFGSURBVEjH7ZQ9bsJAEIW/RYu2oqRxQxFxBxrfwBdAuZHvEeUCvgENN6DxBRAFINvsrlxsCrTYsbHJ30aKlFd5Zt/MmzcaWcRx7DabDWmakuc5obBcLpE+sNZircU5B4AQ4m5R+9051+PdywEYYxoxrTVa62DOtNaN2OVywRgTTKyqqkasqiqMMb01dVfaXtPQGrv1PbGiKIKusSzLRux0Ot2cdafy6Lptc4cceu7xeHwvFtLZ+XxuxPb7PUVRDJIPh8Nos/l8Pvo+m82Y+KCua0KiruvGmZSS6XQ6SI6iaLTZWK3vL9vkob/GT+AmppS6BlIigNsdee3eYYpOUtwhtXPXbwlsF4vFarfboZTCWhvEmVIKEcfxE5ADW2AV8kjEC/CaJACss2yU7HlfQZZlyGcgedDs0RAfxST5xrSfwW/p/OMP4w3tcqDExRHCHwAAAABJRU5ErkJggg==', | |
openSwitch: 'data:image/gif;base64,R0lGODlhEAAQAJECAP///6uopv///wAAACH5BAEAAAIALAAAAAAQABAAAAIbVI6Zpu0PIwRAImoPjrT353nSZpFjlaWqxbAFADs=', | |
closeSwitch: 'data:image/gif;base64,R0lGODlhEAAQAJECAP///6uopv///wAAACH5BAEAAAIALAAAAAAQABAAAAIWVI6Zpu0Po5y0JoAzflrbD4aixUxCAQA7', | |
o: 'data:image/gif;base64,R0lGODlhEA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vDNEdHNMMALy+MgQA7' | |
} | |
//----------------------------------------------------------------------------- | |
// 設定ここまで | |
//----------------------------------------------------------------------------- | |
var SETTINGS = ''; | |
var FluJE = { | |
resultList: [], | |
resultCloseFlag: false, | |
selectionFlag: true, | |
//=== remove result calame === | |
removeResult: function (e) { | |
var navi = $('FluJE_navi'); | |
var selection = window.getSelection().toString(); | |
if(selection!="" || !FluJE.resultCloseFlag) return; | |
if(navi && navi.style.display!='none') return; | |
if(SETTINGS.remove_result_all){ | |
if(FluJE.resultList.length){ | |
FluJE.resultList.forEach(function (c_node){ | |
document.body.removeChild(c_node); | |
}); | |
FluJE.resultList = []; | |
FluJE.resultCloseFlag = false; | |
} | |
}else{ | |
var result = FluJE.resultList[FluJE.resultList.length-1]; | |
if(result){ | |
document.body.removeChild(result); | |
FluJE.resultList.pop(); | |
} | |
} | |
}, | |
//=== All close (remove result calame and close navi calame) === | |
allRemove: function(){ | |
var navi = $('FluJE_navi'); | |
var qlookup = $('FluJE_quick_lookup'); | |
if(qlookup){ | |
qlookup.style.display = 'none'; | |
qlookup.style.opacity = 0; | |
} | |
if(navi){ | |
navi.style.display = 'none'; | |
navi.style.opacity = 0; | |
} | |
if(FluJE.resultList.length){ | |
FluJE.resultList.forEach( | |
function (e){ document.body.removeChild(e); }); | |
FluJE.resultList = []; | |
} | |
}, | |
//=== Mouseup Event (selection) === | |
selectionEvent: function(evt, ids, force){ | |
var self = FluJE; | |
var selection = window.getSelection().toString(); | |
if(!selection || !FluJE.selectionFlag) return; | |
FluJE.resultCloseFlag = false; | |
setTimeout(function(){ FluJE.resultCloseFlag = true }, 100); | |
if(!force) { | |
if(SETTINGS.enable_modifier_key){ | |
if(!(evt[SETTINGS.modifier_key]) || evt.button != 0 ) | |
return; | |
}else{ | |
if(evt[SETTINGS.modifier_key] || evt.button != 0) | |
return; | |
else if(selection) | |
setTimeout(function(){ return; }, 100); | |
} | |
} | |
if(ids && ids.length) | |
FluJE.showResult(selection, self.autoSelector(selection, ids)); | |
else | |
FluJE.showResult(selection, self.autoSelector(selection)); | |
window.getSelection().removeAllRanges(); | |
}, | |
//=== select site(s) automatic === | |
autoSelector: function(str, ids){ | |
var ids_ja = [], ids_en = [], type = "", lang = ""; | |
if(ids && ids.length){ | |
ids.forEach(function(val){ | |
if(checkInputLang(val, 'ja')) | |
ids_ja.push(val); | |
if(checkInputLang(val, 'en')) | |
ids_en.push(val); | |
}); | |
}else | |
ids = [] | |
str = str.replace(/^\s+|\s+$/g, ""); | |
if(!str.match(/^[\S]+\s.*$/i)){ | |
var re = new RegExp("[^a-z0-9]{"+SETTINGS.translation.ja_chars+",}", "i"); | |
if(/^\s*$|[^a-z\s]/i.test(str)){ | |
lang = "ja"; | |
if(SETTINGS.lookup.ja_type=='search') | |
type = 'lookup'; | |
else if(re.test(str) && SETTINGS.translation.JtoE) | |
type = 'translation' | |
else | |
type = 'lookup' | |
}else { | |
lang = 'en'; | |
type='lookup'; | |
} | |
}else { | |
lang = 'en' | |
if(SETTINGS.lookup.en_type=='search') | |
type = 'lookup' | |
else if((str.match(/\s/mg).length >= SETTINGS.translation.en_words-1) && SETTINGS.translation.EtoJ) | |
type = 'translation' | |
else | |
type = 'lookup' | |
} | |
if(ids.length){ | |
if(lang == 'ja') | |
return ids_ja; | |
else if (lang == 'en') | |
return ids_en; | |
else return; | |
} | |
if(SETTINGS[type][lang] && SETTINGS[type][lang].length) | |
return SETTINGS[type][lang]; | |
}, | |
//----------------------------------------------------------------------------- | |
// output result gotten from keyword | |
//----------------------------------------------------------------------------- | |
//=== show results === | |
loaded: false, | |
initCSS: function(){ | |
var cls1 = 'div.FluJE_result', cls2 = cls1+' div.FluJE_result_area', cls3 = cls2+' div.FluJE_result_article'; | |
var inherit = 'background: inherit; background-image: inherit; background-color: inherit; color: inherit; text-align: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; margin: inherit; text-decoration: inherit; border: 0px; height: auto; padding: 0; font-family: inherit; vertical-align: inherit; line-height: inherit; font-stretch: inherit; font-variant: inherit; font-size-adjust: inherit; letter-spacing: inherit;'; | |
var css = [ cls1,'{ font-size: 14px; position: fixed; margin: 0; padding: 0; bottom: 0; left: 0; right: 0; max-height: 50%; overflow: auto; vertical-align: baseline; border: 0; border-collapse: separate; text-align: left; text-indent: 0; text-decoration: none; color: #FFF; font-family: sans-serif; font-weight: normal; font-style: normal; font-size: medium; font-stretch: normal; font-variant: normal; font-size-adjust: none; letter-spacing: normal; background: none; background-color: #000; background-image: none; -moz-border-radius: 3px; opacity: 0.8; z-index: 1000; }\n', | |
cls1,' > div{',inherit,' min-height: 22px; }\n', | |
cls1,' img.FluJE_switch_img{ position: absolute; cursor: pointer; top: 1px; right: 1px; margin: 3px 2px 0 5px; width: 16px; height: 16px; z-index: 3000; }\n', | |
cls2,'{ position: relative; overflow: auto; z-index: 1500; }\n', | |
cls3,'{ position: relative; -moz-border-radius: 3px; color: #FFF; background-color: #111; margin: 5px; padding: 3px 0 0 30px; z-index: 1000; min-height: 22px; }\n', | |
cls3,' span.indicator{ ',inherit,' position: absolute; top: 0; color: #FFF; left: 40px; width: 200px; height: 18px; padding-left: 30px; background-image: url(',IMAGES.indicator,'); background-repeat: no-repeat; z-index: 3000; }\n', | |
cls3,' *{',inherit,' background-color: #111; margin: 0; padding: 0; color: #FFFFFF; font-size: 14px; }\n', | |
cls3,' h1, ',cls3,' h2{ width: 100%; max-width: 100%; font-size: 110%; height: auto; font-weight: bold; color: #9FF; }\n', | |
cls3,' h1 *, ',cls3,' h2 *{ width: 100%; max-width: 100%; font-size: 110%; height: auto; font-weight: bold; color: #9FF; }\n', | |
cls3,' h3, ',cls3,' h4, ',cls3,' h5, ',cls3,' h6{ width: 100%; max-width: 100%; height: auto; color: #9F9; font-size: 95%; font-weight:100%; }\n', | |
cls3,' h3 *, ',cls3,' h4 *, ',cls3,' h5 *, ',cls3,' h6 *{ width: 100%; max-width: 100%; height: auto; color: #9F9; font-size: 95%; font-weight:100%; }\n', | |
cls3,' strong, ',cls3,' em{ color: #F99; font-size: 105%; font-weight: bold; }\n', | |
cls3,' strong *, ',cls3,' em *{ color: #F99; font-size: 105%; font-weight: bold; }\n', | |
cls3,' tr td{ padding: 7px; }\n', | |
cls3,' a{ color: #FF9; text-decoration: none; }\n', | |
cls3,' a:hover{ color: #FF9; text-decoration: underline; }\n', | |
cls3,' img{ display: none; }\n', | |
cls3,' a.FluJE_permalink{ position: absolute; padding: 0; margin: 0; top: 0px; left: 2px; text-decoration: none; width: 0; height: 0; color: none; border:0; background-color: none; }\n', | |
cls3,' img.FluJE_site_icon{ position: absolute; -moz-border-radius: 3px; top: 0px; left: 2px; width: 16px; height: 16px; padding: 1px; background-color: #FFF; display: inline; }\n', | |
cls3,' span.FluJE_msg{ padding-left: 10px; color: #999; }\n', | |
cls3,' span.FluJE_error_msg{ padding-left: 10px; color: #999; }\n', | |
'div#FluJE_flash_msg{ position: fixed; bottom: 0; left: 0; right: 0; color: #9F9; font-weight: normal; font-size: 90%; text-align: center; background-color: #000; padding: 5px 0; margin: 0; opacity: 0.8; }\n', | |
'div#FluJE_flash_error_msg{ position: fixed; bottom: 0; left: 0; right: 0; color: #F99; font-weight: bold; font-size: 120%; text-align: center; background-color: #000; padding: 5px 0; margin: 0; opacity: 0.8; }\n' | |
].join(''); | |
return css; | |
}, | |
showMessage: function(str, param){ | |
var self = FluJE; | |
if(!str) return; | |
if(!self.loaded) loadStyle(self.loaded, self.initCSS()); | |
if(param == "error") | |
var msg = document.body.appendChild($N('div', {id:'FluJE_flash_error_msg', style:'display: none'}, str)); | |
else | |
var msg = document.body.appendChild($N('div', {id:'FluJE_flash_msg', style:'display: none'}, str)); | |
Effect.flash(msg); | |
return; | |
}, | |
showResult: function(str, items){ | |
var self = FluJE; | |
if(!str) return; | |
if(loadStyle(self.loaded, self.initCSS(), function(){ self.showResult(str, items); })){ | |
self.loaded = true; | |
return; | |
} | |
if(!items){ | |
var items = self.autoSelector(str); | |
if(!items){ | |
var msg = document.body.appendChild($N('div', {id:'FluJE_flash_error_msg', style:'display: none'}, '!!! Plese select one or more sites. !!!')); | |
Effect.flash(msg); | |
return; | |
} | |
} | |
var root = document.body.appendChild($N('div', {class:'FluJE_result'})); | |
ResultNavi.init(root, str); | |
self.resultList.push(root); | |
root.addEventListener('click', function(evt) { | |
evt.stopPropagation(); | |
var tag_name = evt.target.nodeName; | |
if(tag_name=='IMG' || tag_name=='A' || !self.resultCloseFlag || window.getSelection().toString()!="") return; | |
document.body.removeChild(root); | |
self.resultList.pop(); | |
}, false); | |
var result_elems = [], indicator = [], permalinks = []; | |
var indicator_img = $N('span', {class:'indicator', style:'display: inline'}, 'Now Loading...'); | |
items.forEach(function (num, index){ | |
indicator.push(indicator_img.cloneNode(true)); | |
var site_icon = $N('img', {class:'FluJE_site_icon', src: getIcon(num), title: SITEINFO[num].name}); | |
permalinks.push($N('a', {class:'FluJE_permalink', target: '_blank'}, [site_icon])); | |
result_elems.push($N('div',{class:'FluJE_result_article'}, [permalinks[index], indicator[index]])); | |
}); | |
var area = root.appendChild($N('div', {class:'FluJE_result_area'}, result_elems)); | |
self.getResults(str, items, function(results, index, hash){ | |
if(hash){ | |
var num = hash.num; | |
var url = hash.url; | |
} | |
permalinks[index].setAttribute('href', url); | |
indicator[index].style.display = 'none'; | |
results.forEach(function (e){ | |
e = document.importNode(e, true); | |
result_elems[index].appendChild(e); | |
}); | |
self.resultCloseFlag = true; | |
}); | |
}, | |
createElements: function(req, sites, url, index, num, func) { | |
var info = sites[num]; | |
var r = req.responseText.replace(/<object[\S\s]+<\/object>/img, ''); | |
var reqdom = convertToHTMLDocument(r); | |
var tmp = []; | |
var results = []; | |
tmp = $X(info.xpath, reqdom); | |
if(tmp!='' && (info.NGxpath==null || (info.NGxpath && $X(info.NGxpath, reqdom)==''))){ | |
if(info.type=='dictionary' || info.type=='search'){ | |
tmp.forEach(function(result) { | |
var links = $X(".//a", result); | |
links.forEach(function(link){ | |
if(link.getAttribute("href") && link.getAttribute("href").charAt(0) != "#"){ | |
if(link.getAttribute("href").toLowerCase().indexOf("http") != 0){ | |
if(info.link){ | |
link.setAttribute("href",info.link+link.getAttribute("href").replace(new RegExp('[0-9a-z/.+-]*/', 'i') ,"")); | |
}else{ | |
link.setAttribute("href", | |
url.match(new RegExp('http://[0-9a-z/.+-]+/', 'i')) | |
+link.getAttribute("href").replace(new RegExp('[0-9a-z/.+-]*/') ,"")); | |
} | |
} | |
link.setAttribute("target","_blank"); | |
}else if(link.hasChildNodes()){ | |
link.removeAttribute('href'); | |
} | |
}); | |
results.push(result); | |
}); | |
}else if(info.type=='translation'){ | |
tmp.forEach(function(result){ | |
results.push(result); | |
}); | |
} | |
}else{ | |
results.push($N('span', {class: 'FluJE_error_msg'}, 'Not Found')); | |
} | |
func(results, index, {num:num, url:url}); | |
}, | |
//=== get results === | |
/* func::argument (1st:Results(Array), 2nd:Site Number, 3rd: Result URL) */ | |
getResults: function(str, items, func){ | |
var sites = SITEINFO; | |
if(!items) return; | |
items.forEach(function (e, index){ | |
var data = '', method = 'GET', url = ''; | |
if(sites[e].enc && (sites[e].lang=='ja' || sites[e].lang=='both')){ | |
var cs = EscapeEncoding(sites[e].enc, str); | |
}else{ | |
var cs = str.replace(/’/mg, "\'").replace(/,/mg, ','); | |
} | |
if(sites[e].type=='dictionary'){ | |
url = sites[e].url.replace(/\[context\]/, cs); | |
}else if(sites[e].type=='search'){ | |
cs = cs.replace(/\s/mg, sites[e].space); | |
url = sites[e].url.replace(/\[context\]/, cs); | |
}else if(sites[e].type=='translation'){ | |
if(sites[e].method=='POST'){ | |
method = 'POST'; | |
url = sites[e].url; | |
if(sites[e].lang == 'ja'){ | |
data = sites[e].data.replace(/\[context\]/, cs); | |
}else if(sites[e].lang == 'en'){ | |
data = sites[e].data.replace(/\[context\]/, cs.replace(/\s/mg, sites[e].space)); | |
} | |
}else{ | |
cs = cs.replace(/\s/mg, sites[e].space); | |
url = sites[e].url.replace(/\[context\]/, cs); | |
} | |
} | |
GM_xmlhttpRequest({ | |
overrideMimeType:"text/html; charset="+sites[e].enc, | |
method: method, | |
url: url, | |
headers: { | |
'User-agent': 'Mozilla/5.0 (compatible)', | |
'Content-Type' : 'application/x-www-form-urlencoded', | |
'Accept': 'application/atom+xml,application/xml,text/xml', | |
}, | |
data: data, | |
onerror: function(){ | |
func([$N('span', {class: 'FluJE_error_msg'}, 'ERROR')], e, url); | |
return; | |
}, | |
onload: function(res) { | |
FluJE.createElements(res, sites, url, index, e, func); | |
} | |
}); | |
}); | |
}, | |
getSiteInfo : function() { | |
var a = []; | |
var cache = eval(GM_getValue("cacheInfo")); | |
if(!cache) { | |
this.importSiteInfo(); | |
return ; | |
} | |
a = a.concat(LOCAL_SITEINFO); | |
SITEINFO_IMPORT_URLS.forEach(function(i) { | |
a = a.concat(cache[i].info); | |
}); | |
a.forEach(function(val,index){ | |
a[index].id = index; | |
}); | |
return a; | |
}, | |
importSiteInfo: function(){ | |
if (document.getElementById('FluJE_navi')){ | |
var node = document.getElementById('FluJE_navi'); | |
node.parentNode.removeChild(node); | |
} | |
SITEINFO_IMPORT_URLS.forEach(function(i) { | |
var opt = { | |
method: 'get', | |
url: i, | |
onload: function(res) { | |
FluJE.showMessage("import site info."); | |
return FluJE.getCacheCallback(res, i); | |
}, | |
onerror: function(res){ | |
FluJE.showMessage("import error.", "error"); | |
}, | |
} | |
GM_xmlhttpRequest(opt); | |
}) | |
}, | |
getCacheCallback: function(res, url) { | |
if (res.status != 200) { | |
return getCacheErrorCallback(url); | |
} | |
var info = null; | |
try { | |
info = eval(res.responseText).map(function(i) { return i.data }) | |
} | |
catch(e) { | |
info = [] | |
var matched = false | |
var hdoc = convertToHTMLDocument(res.responseText) | |
var textareas = $X('.//*[@class="FluJE_data"]', hdoc) | |
textareas.forEach(function(textarea) { | |
var d = parseInfo(textarea.value) | |
if (d) { | |
info.push(d) | |
if (!matched && location.href.match(d.url)) { | |
matched = d | |
} | |
} | |
}) | |
} | |
if (info.length > 0) { | |
cacheInfo = {} | |
cacheInfo[url] = { | |
url: url, | |
expire: new Date(new Date().getTime()), | |
info: info | |
} | |
GM_setValue('cacheInfo', cacheInfo.toSource()) | |
SITEINFO = this.getSiteInfo(); | |
}else { | |
this.getCacheErrorCallback(url) | |
} | |
}, | |
getCacheErrorCallback: function(url) { | |
var expire = new Date(new Date().getTime()) | |
var chacheInfo = {} | |
if (cacheInfo[url]) { | |
cacheInfo[url].expire = expire | |
} | |
else { | |
cacheInfo[url] = { | |
url: url, | |
expire: expire, | |
info: [] | |
} | |
} | |
GM_setValue('cacheInfo', cacheInfo.toSource()) | |
}, | |
//=== window onLoad === | |
onLoad: function(){ | |
//== GM_getValue == | |
Setting.load(); | |
SITEINFO = FluJE.getSiteInfo(); | |
//== Userscript command == | |
GM_registerMenuCommand('Fast look up JP and EN - reset setting', function(){Setting.reset()}); | |
//== Event == | |
ShortcutKey.add(window, SETTINGS.shortcutkey.navi_toggle, Navi.toggle); | |
ShortcutKey.add(window, SETTINGS.shortcutkey.close_all, FluJE.allRemove, true); | |
ShortcutKey.add(window, SETTINGS.shortcutkey.QL_run, QLu.run); | |
if(SETTINGS.shortcutkey.site.length){ | |
var keys = []; | |
if(SETTINGS.shortcutkey.site.length) { | |
SETTINGS.shortcutkey.site.forEach(function(v,i){ | |
var match = false; | |
keys.forEach(function(key, idx){ | |
if(key.shortcutkey == v.shortcutkey) { | |
keys[idx].id.push(v.id); | |
match = true; | |
} | |
}); | |
if(!match) | |
keys.push({shortcutkey:v.shortcutkey, id:[v.id]}); | |
}); | |
} | |
if(keys.length) { | |
keys.forEach(function(key, idx){ | |
ShortcutKey.add(window, key.shortcutkey, function(evt){ | |
FluJE.selectionEvent(evt, key.id, true); | |
}, false); | |
}); | |
} | |
} | |
window.addEventListener("mouseup", FluJE.selectionEvent, true); | |
window.addEventListener('click', FluJE.removeResult, false); | |
GM_registerMenuCommand('Fast look up JP and EN - import siteinfo', function(){ | |
FluJE.importSiteInfo(); | |
}); | |
if(SETTINGS.enable_wheel_button) { | |
window.addEventListener('click', function(e){ | |
if(e.button==1) | |
FluJE.selectionEvent(e, false, true); | |
}, false); | |
} | |
}, | |
} | |
//----------------------------------------------------------------------------- | |
// EFFECT | |
//----------------------------------------------------------------------------- | |
var Effect = { | |
flag: true, | |
flash: function(node){ | |
var self = this; | |
this.fadeio(node); | |
setTimeout(function(){ self.fadeio(node, null, true); }, 2000); | |
}, | |
highlight: function(node, bool){ | |
if(bool){ | |
node.style.backgroundColor = '#CFC'; | |
setTimeout(function(){ node.style.backgroundColor='#FFF'; }, 500); | |
}else{ | |
node.style.backgroundColor = '#F99'; | |
setTimeout(function(){ node.style.backgroundColor='#FFF'; }, 500); | |
} | |
}, | |
smoothsize: function(node, original, fixed) { | |
var self = this; | |
if(original > fixed) { | |
node.offsetHeight -= 5; | |
orininal -= 5; | |
setTimeout(function(){ | |
self.smoothsize(node, original, fixed); | |
}, 20); | |
} | |
return; | |
}, | |
fadeio: function(node, func, rm, sw, count){ | |
var self = this; | |
if(!sw){ | |
if(!this.flag) return; | |
if(!node.style.opacity) node.style.opacity = 0; | |
if(node.style.display=='none') node.style.display = 'block'; | |
if(parseFloat(node.style.opacity) > 0.5) { | |
sw = 'out', count = 8, this.flag = false; | |
}else{ | |
sw = 'in', count = 0, this.flag = false; | |
} | |
} | |
if(!SETTINGS.effect){ | |
if(sw=='in') { | |
node.style.opacity = 0.8; | |
this.flag = true; | |
}else { | |
node.style.opacity = 0; | |
node.style.display = 'none'; | |
this.flag = true; | |
} | |
if(func) setTimeout(func, 10); | |
return; | |
} | |
if(sw == 'in'){ | |
if(count <= 8){ | |
node.style.opacity = count/10; | |
count++; | |
setTimeout(function(){ | |
self.fadeio(node, func, rm, sw, count); | |
}, 20); | |
}else{ | |
if(func) func(); | |
this.flag = true; return; | |
} | |
}else if(sw == 'out'){ | |
if(count >= 0){ | |
node.style.opacity = count/10; | |
count--; | |
setTimeout(function(){ | |
self.fadeio(node, func, rm, sw, count); | |
}, 20); | |
}else{ | |
if(func) func(); | |
if(rm) node.parentNode.removeChild(node); | |
else node.style.display = 'none'; | |
this.flag = true; return; | |
} | |
} | |
} | |
} | |
//----------------------------------------------------------------------------- | |
// Navigation | |
//----------------------------------------------------------------------------- | |
var Navi = { | |
loaded: false, | |
initCSS: function() { | |
var id1 = 'div#FluJE_navi', id2 = id1+' div#FluJE_navi_container', cls1 = id2+' table.FluJE_navi_table', cls2_1 = cls1+' .FluJE_site_num_ja', cls2_2 = cls1+' .FluJE_site_num_en', id3 = id2+' div#FluJE_navi_setting'; | |
var inherit = 'background:inherit; background-image:inherit; background-color:inherit; color:inherit; text-align:inherit; font-size:inherit; font-style:inherit; font-weight:inherit; margin:inherit; text-decoration:inherit; border:0px; font-family:inherit; vertical-align:inherit; line-height:inherit; font-stretch:inherit; font-variant:inherit; font-size-adjust:inherit; letter-spacing:inherit;'; | |
var css = [ id1,'{ position: fixed; margin: 0; padding: 28px 10px 20px 5px; top: 10px; left: 10px; width: 400px; height: 400px; max-height: 100%; vertical-align: baseline; border: 0; border-collapse: separate; text-align: left; text-indent: 0; text-decoration: none; color: #FFF; font-family: sans-serif; font-weight: normal; font-style: normal; font-size: 9pt; font-stretch: normal; font-variant: normal; font-size-adjust: none; letter-spacing: normal; background: none; background-color: #000; background-image: none; -moz-border-radius: 10px; opacity:0.8; z-index:1000; }\n', | |
id1,' div#FluJE_navi_title{ ',inherit,' position: absolute; top: 3px; left: 10px; }\n', | |
id1,' div#FluJE_navi_title span{ ',inherit,' font-size: 10pt; color: #999; font-weight: bold; }\n', | |
id1,' div#FluJE_navi_title span#FluJE_navi_version{ ',inherit,' font-size: 90%; margin-left: 10px; color: #666; font-weight: normal; }\n', | |
id1,' .FluJE_navi_button{ position: absolute; cursor: pointer; width: 27px; height: 23px; }\n', | |
id1,' div#FluJE_navi_minimize_button{ top: 5px; right: 64px; background: url(',IMAGES.minimize,') no-repeat; }\n', | |
id1,' div#FluJE_navi_minimize_button:hover{ background: url(',IMAGES.minimize_focused,') no-repeat; }\n', | |
id1,' div#FluJE_navi_maximize_button{ top: 5px; right: 37px; background: url(',IMAGES.maximize,') no-repeat; }\n', | |
id1,' div#FluJE_navi_maximize_button:hover{ background: url(',IMAGES.maximize_focused,') no-repeat; }\n', | |
id1,' div#FluJE_navi_close_button{ top: 5px; right: 10px; background: url(',IMAGES.close,') no-repeat; }\n', | |
id1,' div#FluJE_navi_close_button:hover{ background: url(',IMAGES.close_focused,') no-repeat; }\n', | |
id1,' span.FluJE_navi_title{ ',inherit,' color: #FFF; font-weight: bold; margin-top: 5px; }\n', | |
id2,'{ ',inherit,' position: static; top: 25px; height: 100%; max-height: 100%; width: 99%; padding: 5px; max-height: auto; overflow-y: auto; overflow-x: hidden; vertical-align: middle; border-top: 1px dashed #666; border-bottom: 1px dashed #666; }\n', | |
id2,' div.FluJE_navi_table_area{ ',inherit,' width: 98%; padding: 5px 3px; margin-bottom: 10px; border: 1px solid #666; }\n', | |
id2,' div.FluJE_navi_reset{ ',inherit,' float: right; border: 1px solid #999; background-color: #333; color: #F33; cursor: pointer; padding: 0 3px; }\n', | |
cls1,'{ ',inherit,' width: 100%; border: 0; margin: 0; vertical-align: middle; border-collapse: separate; border-spacing: 2px; }\n', | |
cls1,' tbody{ ',inherit,' width: 100%; margin: 0; vertical-align: middle; }\n', | |
cls1,' tr, ',cls1,' td{ ',inherit,' font-size: 95%; background-color: #000; padding: 3px; margin: 0; }\n', | |
cls1,' tr *, ',cls1,' td *{ ',inherit,' background-color: #000; }\n', | |
cls1,' tr td input, ',cls1,' select{ background-color: #FFF; color: #000; height: 20px; width: 220px; float: right; }\n', | |
cls1,' tr td input.FluJE_navi_site_sc{ background-color: #FFF; color: green; text-align: center; font-weight: bold; height: 20px; width: 50px; float: right; }\n', | |
cls1,' tr td input:hover, ',id2,' tr td select:hover{ ',inherit,' color: #000; background-color: #FFF; -moz-outline: 2px solid -moz-rgba(16,96,146,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; }\n', | |
cls1,' tr td input[type=\"text\"]:focus, ',id2,' tr td select:focus{ ',inherit,' color: #000; background-color: #FFF; -moz-outline: 2px solid -moz-rgba(16,186,224,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; }\n', | |
cls1,' th { ',inherit,' font-weight: bold; }\n', | |
cls1,' span{ color: #FFF; background-color: inherit; border: 0px; font-size: 9.5pt; float: left; }\n', | |
cls1,' span.FluJE_navi_site_name{ display: none; }\n', | |
cls1,' .FluJE_site_number{ font-size: 10pt; font-weight: bold; text-align: center; width: 16px; height: 16px; background-color: inherit; display: block; }\n', | |
cls1,' td.FluJE_site_num_ja[state=enable]:hover{ -moz-outline: 1px solid -moz-rgba(16,96,146,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; background-color: #006; }\n', | |
cls1,' td.FluJE_site_num_en[state=enable]:hover{ -moz-outline: 1px solid -moz-rgba(146,96,16,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; background-color: #600; }\n', | |
cls1,' img.FluJE_navi_icon{ padding: 1px; width: 16px; height: 16px; -moz-border-radius: 3px; background-color: #FFF; margin-right: 5px; float: left; }\n', | |
cls1,' th{ ',inherit,' text-align: center; color: #CCC; font-weight: normal; padding: 0px; }\n', | |
cls1,' th.Flu_navi_setting_title{ ',inherit,' color: #999; font-weight: bold; font-size: 10pt; }\n', | |
cls2_1,'{ background-color: #003; width: 16px; text-align: center; vertical-align: middle; cursor: pointer; }\n', | |
cls2_2,'{ background-color: #300; width: 16px; text-align: center; vertical-align: middle; cursor: pointer; }\n', | |
id3,' input[type=text]{ width: 75px; float: left; padding-left: 3px; }\n', | |
id3,' input[type=checkbox]{ width: auto; float: left; }\n', | |
id3,' select{ margin: 0; padding: 0; background-color: #FFF; color: #000; width: auto; float: left; }\n', | |
id3,' select option{ background-color: #FFF; color: #000;}\n' | |
].join(''); | |
return css; | |
}, | |
//=== create dictionary search translation table === | |
createMainHTML: function() { | |
var html_dict = "", html_search = "", html_trans = "", html_setting = ""; | |
html_dict += "<div class='FluJE_navi_table_area'><div class='FluJE_navi_reset' evt='reset_lookup'>reset</div><span class='FluJE_navi_title'>Dictionary</span>" | |
+ "<table class='FluJE_navi_table'><tbody>" | |
+ "<tr><th class='FluJE_site_num_ja'>Ja</th><th class='FluJE_site_num_en'>En</th><th>Icon</th><th>Search form</th><th>Shortcut</th></tr>"; | |
html_search += "<span class='FluJE_navi_title'>Search</span>" | |
+ "<table class='FluJE_navi_table'><tbody>"; | |
html_trans += "<div class='FluJE_navi_table_area'><div class='FluJE_navi_reset' evt='reset_translation'>reset</div><span class='FluJE_navi_title'>Translation</span>" | |
+ "<table class='FluJE_navi_table'><tbody>"; | |
var item_length = SITEINFO.length; | |
for(var i=0; i<item_length; i++){ | |
var site_name = SITEINFO[i].name, site_name_rev = ''; | |
var html = "", key = "", type = SITEINFO[i].type, lang = SITEINFO[i].lang, id = SITEINFO[i].id; | |
if(SETTINGS.shortcutkey.site && SETTINGS.shortcutkey.site.length > 0){ | |
SETTINGS.shortcutkey.site.forEach(function(val,idx){ | |
if(val.id == i) | |
key = val.shortcutkey; | |
}); | |
} | |
var sort = (type == 'translation') ? 'translation' : 'lookup'; | |
html+="<tr><td class='FluJE_site_num_ja' name=\'ja:"+type+"\' site_id="+id+" sort="+sort+" alt='site_number' evt='chenge_site_num' state="+(function(){ if(lang=='ja' || lang=='both') return 'enable'; else 'disable'; })()+">"+SiteNumElement.get(i, 'ja', 'html')+"</td>" | |
+ "<td class='FluJE_site_num_en' name=\'en:"+type+"\' site_id="+id+" sort="+sort+" alt='site_number' evt='chenge_site_num' state="+(function(){ if(lang=='en' || lang=='both') return 'enable'; else 'disable'; })()+">"+SiteNumElement.get(i, 'en', 'html')+"</td>" | |
+ "<td><img class='FluJE_navi_icon' title=\'"+site_name+"\' src=\'"+getIcon(i)+"\'><span class='FluJE_navi_site_name'>"+site_name+"</span></td>" | |
+ "<td><input class='FluJE_navi_inputtext' evt='lookup' type='text' size=30 name="+i+"></td>" | |
+ "<td><input class='FluJE_navi_site_sc' site_id="+id+" evt='shortcut' type='text' size=5 name="+i+" value="+key+"></td></tr>"; | |
if(type == 'dictionary') | |
html_dict += html; | |
else if(type=='search') | |
html_search += html; | |
else if(type=='translation') | |
html_trans += html; | |
} | |
html_dict += "</tbody></table>"; | |
html_search += "</tbody></table></div>"; | |
html_trans += "</tbody></table></div>"; | |
return html_dict + html_search + html_trans; | |
}, | |
//=== crate setting table === | |
createSettingHTML: function() { | |
var html = "<div class='FluJE_navi_reset' evt='reset_setting'>reset</div><span class='FluJE_navi_title'>Setting</span>" | |
+ "<table class='FluJE_navi_table'><tbody>" | |
+ "<tr><th title='検索結果をクリック時に、現在表示している結果すべて消すか、クリックした結果のみ消すか'>表示中の結果を全消去</th>" | |
+ "<td><input type='checkbox' evt='remove_result_all' "+(function(){if(SETTINGS['remove_result_all']) return 'checked'})()+"></td></tr>" | |
+ "<tr><th title='ブラウザ上の文字列選択における辞書引き/検索/翻訳時に修飾キーを利用するか'>修飾キーを有効</th>" | |
+ "<td><input type='checkbox' evt='enable_modifier_key' "+(function(){ if(SETTINGS['enable_modifier_key']) return 'checked'})()+"></td></tr>" | |
+ "<tr><th title='Alt, Control, Shift, Metaキーの何れかを選択してください'>修飾キー</th>" | |
+ "<td><input class='FluJE_navi_inputtext' type='text' evt='modifier_key' value="+SETTINGS.modifier_key+"></td></tr>" | |
+ "<tr><th title='ポップアップ表示時のフェードイン,フェードアウトを有効にするか'>エフェクトを有効</th>" | |
+ "<td><input type='checkbox' evt='check_effect' "+(function(){ if(SETTINGS['effect']) return 'checked'})()+"></td></tr>" | |
+ "<tr><th colspan=2 class='Flu_navi_setting_title'>[ Translation ]</th><td></td></tr>" | |
+ "<tr><th title='日英翻訳を有効にするか チェックしていない場合は辞書引き/検索のみとなります'>日英翻訳を有効</th>" | |
+ "<td><input type='checkbox' evt='Ja_to_En' "+(function(){if(SETTINGS.translation['JtoE']) return 'checked'})()+"></td></tr>" | |
+ "<tr><th title='ここで決められた文字数以上は翻訳されます'>辞書引き上限文字数</th>" | |
+ "<td><input class='FluJE_navi_inputtext' evt='Ja_char' type='text' value="+SETTINGS.translation['ja_chars']+"> (Push ENTER)</td></tr>" | |
+ "<tr><th title='英日翻訳を有効にするか チェックしていない場合は辞書引き/検索のみとなります'>英日翻訳を有効</th>" | |
+ "<td><input type='checkbox' evt='En_to_Ja' "+(function(){if(SETTINGS.translation['EtoJ']) return 'checked'})()+"></td></tr>" | |
+ "<tr><th title='ここで決められた単語数以上は翻訳されます'>辞書引き上限単語数</th>" | |
+ "<td><input class='FluJE_navi_inputtext' type='text' evt='En_word' value="+SETTINGS.translation['en_words']+"> (Push ENTER)</td></tr>" | |
+ "<tr><th colspan=2 class='Flu_navi_setting_title'>[ Shortcut Key ](要リロード)</th></tr>" | |
+ "<tr><th title='ショートカットキーにより「Navi」の表示と非表示を切り替えます'>Naviの表示/非表示</th>" | |
+ "<td><input class='FluJE_navi_inputtext' evt='navi_toggle' type='text' value="+SETTINGS.shortcutkey.navi_toggle+"></td></tr>" | |
+ "<tr><th title='ショートカットキーによりFast look up JP and ENで表示されたポップアップを全て閉じます'>すべて閉じる</th>" | |
+ "<td><input class='FluJE_navi_inputtext' evt='close_all' type='text' value="+SETTINGS.shortcutkey.close_all+"></td></tr>" | |
+ "<tr><th title='ショートカットキーにより「Quick Look up」を起動します'>Quick Lookup</th>" | |
+ "<td><input class='FluJE_navi_inputtext' evt='QL_run' type='text' value="+SETTINGS.shortcutkey.QL_run+"></td></tr>" | |
+ "</tbody></table>"; | |
return html; | |
}, | |
getHTML: function() { | |
var html = "<div id='FluJE_navi_title'><span>Fast look up JP and EN</span><span id='FluJE_navi_version'>ver."+VERSION+"<span></div>" | |
+ "<div class='FluJE_navi_button' id='FluJE_navi_minimize_button' evt='minimize'></div>" | |
+ "<div class='FluJE_navi_button' id='FluJE_navi_maximize_button' evt='maximize'></div>" | |
+ "<div class='FluJE_navi_button' id='FluJE_navi_close_button' evt='close'></div>" | |
+ "<div id='FluJE_navi_container'>" | |
+ Navi.createMainHTML() | |
+ "<div class='FluJE_navi_table_area' id='FluJE_navi_setting'>" | |
+ this.createSettingHTML() + "</div></div>"; | |
return html; | |
}, | |
//=== Navi Event === | |
events: function(evt, navi) { | |
var self = this; | |
var tnode = evt.target; | |
var container = $('FluJE_navi_container'); | |
switch(tnode.getAttribute('evt')) { | |
case 'close': { | |
Effect.fadeio(navi); | |
evt.stopPropagation(); break; | |
} | |
case 'minimize': { | |
if(container.style.display != 'none') { | |
container.style.display='none'; | |
navi.style.width = null; | |
navi.style.height = 'auto'; | |
navi.style.bottom = null; break; | |
}else { | |
container.style.display='block'; | |
navi.style.width = null | |
navi.style.height = null; | |
navi.style.bottom = null; break; | |
} | |
} | |
case 'maximize': { | |
var show_site_name = function(disp) { | |
var max_width = 0; | |
$X(".//span[@class='FluJE_navi_site_name']", container).forEach(function(node){ | |
if(disp=='block') { | |
node.style.display="block"; | |
if(max_width < node.offsetWidth) { | |
max_width = (node.offsetWidth*(node.offsetHeight/20)+50) | |
} | |
node.parentNode.style.width = max_width; | |
}else { | |
node.style.display="none"; | |
node.parentNode.style.width=null | |
} | |
}); | |
} | |
if(container.style.display=='none') | |
container.style.display = 'block'; | |
if(navi.style.bottom != '10px') { | |
show_site_name("block"); | |
navi.style.width = 'auto'; | |
navi.style.height = 'auto'; | |
navi.style.bottom = '10px'; | |
}else{ | |
show_site_name("none"); | |
navi.style.height = null; | |
navi.style.width = null; | |
navi.style.bottom = null; | |
} | |
break; | |
} | |
case 'lookup': { | |
if(tnode.getAttribute('added_event')=='true') return; | |
tnode.setAttribute('added_event', true); | |
ShortcutKey.add(tnode, 'RET', function(evt) { | |
FluJE.showResult(tnode.value, [parseInt(tnode.name, 10)]); | |
evt.stopPropagation(); | |
}, false); break; | |
} | |
case 'chenge_site_num': { | |
var modifier_key = evt[SETTINGS.modifier_key]; | |
if(tnode.getAttribute('alt') == 'site_number'){ | |
SiteNumElement.check(tnode, container, modifier_key); | |
break; | |
}else if(tnode.parentNode.getAttribute('alt') == 'site_number'){ | |
SiteNumElement.check(tnode.parentNode, container, modifier_key); | |
break; | |
}else break; | |
} | |
case 'reset_lookup': { | |
SETTINGS.lookup.ja = [], SETTINGS.lookup.en = []; | |
SiteNumElement.replace($X('.//td[@class="FluJE_site_num_ja"][@sort="lookup"]', container), {lang:'ja', sort:'lookup'}); | |
SiteNumElement.replace($X('.//td[@class="FluJE_site_num_en"][@sort="lookup"]', container), {lang:'en', sort:'lookup'}); | |
Setting.save(); | |
break; | |
} | |
case 'reset_translation': { | |
SETTINGS.translation.ja = [], SETTINGS.translation.en = []; | |
SiteNumElement.replace($X('.//td[@class="FluJE_site_num_ja"][@sort="translation"]', container), {lang:'ja', sort:'translation'}); | |
SiteNumElement.replace($X('.//td[@class="FluJE_site_num_en"][@sort="translation"]', container), {lang:'en', sort:'translation'}); | |
Setting.save(); | |
break; | |
} | |
case 'reset_setting': { | |
Setting.reset([['remove_result_all'],['enable_modifier_key'],['modifier_key'],['effect'],['translation','JtoE'],['translation','ja_chars'],['translation','EtoJ'],['translation','en_words'],['shortcutkey']]); | |
$('FluJE_navi_setting').innerHTML = this.createSettingHTML(); | |
break; | |
} | |
case 'remove_result_all': { | |
Setting.set('remove_result_all', tnode.checked); | |
break; | |
} | |
case 'enable_modifier_key': { | |
Setting.set('enable_modifier_key', tnode.checked); | |
break; | |
} | |
case 'modifier_key': { | |
if(tnode.getAttribute('added_event')=='true') return; | |
tnode.setAttribute('added_event', true); | |
tnode.addEventListener('keyup',function(evt){ | |
var key = ''; | |
if(evt.shiftKey || evt.keyCode==16) key = 'shiftKey'; | |
if(evt.ctrlKey || evt.keyCode==17) key = 'ctrlKey'; | |
if(evt.altKey || evt.keyCode==18) key = 'altKey'; | |
if(evt.metaKey || evt.keyCode==224) key = 'metaKey'; | |
tnode.value = key; | |
if(key){ | |
Effect.highlight(tnode, true); | |
Setting.set('modifier_key', key); | |
}else{ | |
Effect.highlight(tnode, false); | |
setTimeout(function(){ tnode.value = SETTINGS.modifier_key; }, 500); | |
} | |
evt.stopPropagation(); | |
}, false); | |
break; | |
} | |
case 'check_effect': { | |
Setting.set('effect', tnode.checked); | |
break; | |
} | |
case 'Ja_to_En': { | |
Setting.set(['translation','JtoE'], tnode.checked); | |
break; | |
} | |
case 'Ja_char': { | |
if(tnode.getAttribute('added_event')=='true') return; | |
tnode.setAttribute('added_event', true); | |
ShortcutKey.add(tnode, 'RET', function(e) { | |
if(isNaN(tnode.value)){ | |
Effect.highlight(tnode, false); | |
}else{ | |
Effect.highlight(tnode, true); | |
Setting.set(['translation','ja_chars'], parseInt(e.target.value, 10)); | |
} | |
}, false); | |
break; | |
} | |
case 'En_to_Ja': { | |
Setting.set(['translation','EtoJ'], tnode.checked); | |
break; | |
} | |
case 'En_word': { | |
if(tnode.getAttribute('added_event')=='true') return; | |
tnode.setAttribute('added_event', true); | |
ShortcutKey.add(tnode, 'RET', function(e) { | |
if(isNaN(tnode.value)){ | |
Effect.highlight(tnode, false); | |
}else{ | |
Effect.highlight(tnode, true); | |
Setting.set(['translation','en_words'], parseInt(e.target.value, 10)); | |
} | |
}, false); | |
break; | |
} | |
case 'navi_toggle': { | |
ShortcutKey.set(tnode, 'navi_toggle'); | |
break; | |
} | |
case 'close_all': { | |
ShortcutKey.set(tnode, 'close_all'); | |
break; | |
} | |
case 'QL_run': { | |
ShortcutKey.set(tnode, 'QL_run'); | |
break; | |
} | |
case 'shortcut': { | |
var index = null, _s = SETTINGS.shortcutkey; | |
var id = tnode.getAttribute('site_id'); | |
if(!_s.site){ | |
SETTINGS.shortcutkey.site = []; | |
}else{ | |
_s.site.forEach(function(val,i){ | |
if(val.id == id) index = i; | |
}); | |
} | |
if(index == null){ | |
_s.site.push({id:parseInt(id)}); | |
index = _s.site.length - 1; | |
} | |
ShortcutKey.set(tnode, 'site', index); | |
break; | |
} | |
default: break; | |
} | |
}, | |
//=== show toggle (open/close) Navi === | |
toggle: function(){ | |
var self = Navi; | |
var navi = $('FluJE_navi'); | |
if(navi){ | |
if(navi.style.display != 'none'){ | |
Effect.fadeio(navi); | |
return; | |
}else{ | |
Effect.fadeio(navi); | |
return; | |
} | |
}else{ | |
if(loadStyle(self.loaded, self.initCSS(), self.toggle)){ | |
self.loaded = true; | |
return; | |
} | |
var navi = document.body.appendChild($N('div', {id:'FluJE_navi'})); | |
navi.innerHTML = self.getHTML(); | |
Effect.fadeio(navi); | |
//== Navi Event Listener == | |
navi.addEventListener('keyup', function(evt){ | |
self.events(evt, navi); | |
}, false); | |
navi.addEventListener('click', function(evt){ | |
self.events(evt, navi); | |
}, false); | |
} | |
} | |
} | |
//----------------------------------------------------------------------------- | |
// Navigation at result area. | |
//----------------------------------------------------------------------------- | |
var ResultNavi = { | |
loaded: false, | |
initCSS: function(){ | |
var cls1 = 'div.FluJE_result div.FluJE_result_navi', cls2 = cls1+' div.FluJE_result_navi_area', cls3_1 = cls2+' td.FluJE_site_num_ja', cls3_2 = cls2+' td.FluJE_site_num_en'; | |
var inherit = 'background: inherit; background-image: inherit; background-color: inherit; color: inherit; text-align: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; margin: inherit; text-decoration: inherit; border: 0px; height: auto; padding: 0; font-family: inherit; vertical-align: inherit; line-height: inherit; font-stretch: inherit; font-variant: inherit; font-size-adjust: inherit; letter-spacing: inherit;'; | |
var css = [ cls1,'{ background: #333; background-image: none; background-color: #333; color: #FFF; text-align: inherit; font-size: 16px; font-style: normal; font-weight: normal; margin: 0; text-decoration: none; border: 0px; font-family: inherit; vertical-align: middle; line-height: 100%; font-stretch: normal; font-variant: normal; font-size-adjust: none; letter-spacing: normal; height: auto; max-height: 70px; padding: 1px 30px 1px 0; }\n', | |
cls1,' *{ ',inherit,' padding: 0; }\n', | |
cls2,'{ padding-top:5px; }\n', | |
cls2,' div{ height: 18px; }\n', | |
cls2,' td{ padding: 0 2px; }\n', | |
cls2,' img.FluJE_site_icon{ -moz-border-radius: 3px; cursor: pointer; background-color: #FFF; padding: 1px; margin: 0; width: 16px; height: 16px; }\n', | |
cls2,' span.FluJE_site_number{ text-align: center; color: #FFF; font-weight: bold; font-size: 14px; }\n', | |
cls2,' table{ vertical-align: middle; border-collapse: separate; border-spacing: 2px; }\n', | |
cls3_1,'{ cursor: pointer; width: 18px; height: 18px; text-align: center; background-color: #335; }\n', | |
cls3_2,'{ cursor: pointer; width: 18px; height: 18px; text-align: center; background-color: #533; }\n', | |
cls3_1,'[state=enable]:hover{ -moz-outline: 1px solid -moz-rgba(16,96,146,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; }\n', | |
cls3_2,'[state=enable]:hover{ -moz-outline: 1px solid -moz-rgba(146,96,16,0.8); -moz-outline-offset: 1px; -moz-outline-radius: 3px; }\n' | |
].join(''); | |
return css; | |
}, | |
createHTML: function(){ | |
var html_icon = "<table><tbody><tr><td>Lang</td>", html_ja = "<tr><td class='FluJE_site_num_ja'>Ja</td>", html_en = "<tr><td class='FluJE_site_num_en' >En</td>"; | |
SITEINFO.forEach(function(e, num){ | |
var type = SITEINFO[num].type, lang = SITEINFO[num].lang, id = SITEINFO[num].id; | |
var sort = (type == 'translation') ? 'translation' : 'lookup'; | |
html_icon += "<td><img class='FluJE_site_icon' evt='relookup' src=\'"+getIcon(num)+"\' title=\'"+e.name+"\' name="+num+"></td>"; | |
html_ja += "<td evt='chenge_site_num' class='FluJE_site_num_ja' alt='site_number' name=\'ja:"+type+"\' site_id="+id+" sort="+sort+" state="+(function(){ if(lang=='ja' || lang=='both') return 'enable'; else return 'disable'; })()+">"+SiteNumElement.get(num, 'ja', 'html')+"</td>"; | |
html_en += "<td evt='chenge_site_num' class='FluJE_site_num_en' alt='site_number' name=\'en:"+type+"\' site_id="+id+" sort="+sort+" state="+(function(){ if(lang=='en' || lang=='both') return 'enable'; else return 'disable'; })()+">"+SiteNumElement.get(num, 'en', 'html')+"</td>"; | |
}); | |
html_icon += "</tr>"; | |
html_ja += "</tr>"; | |
html_en += "</tr></tbody></table>"; | |
return html_icon+html_ja+html_en; | |
}, | |
init: function(pNode, str){ | |
var self = ResultNavi; | |
var root = ''; | |
var oicon = pNode.appendChild($N('img', {class:'FluJE_switch_img', src:IMAGES.openSwitch, style:'display: inline;'})); | |
var cicon = pNode.appendChild($N('img', {class:'FluJE_switch_img', src:IMAGES.closeSwitch, style:'display: none;'})); | |
oicon.addEventListener('click', function(e){ | |
oicon.style.display = 'none'; | |
cicon.style.display = 'inline'; | |
if(!root){ | |
if(loadStyle(self.loaded, self.initCSS(), function(){ root = self.show(pNode, str); })){ | |
self.loaded = true; | |
return; | |
}else{ | |
root = self.show(pNode, str); | |
} | |
}else if(root.style.display == 'none'){ | |
root.style.display='block'; | |
}else{ | |
return; | |
} | |
}, false); | |
cicon.addEventListener('click', function(evt){ | |
oicon.style.display = 'inline'; | |
cicon.style.display = 'none'; | |
root.style.display = 'none'; | |
FluJE.resultCloseFlag = true; | |
}, false); | |
}, | |
show: function(pNode, str){ | |
var root = $N('div', {class: 'FluJE_result_navi'}); | |
var area = root.appendChild($N('div', {class:'FluJE_result_navi_area', style:'display: block; float: right;'})); | |
area.innerHTML = this.createHTML(); | |
area.addEventListener('click', function(evt){ | |
var tnode = evt.target; | |
switch(tnode.getAttribute('evt')){ | |
case 'chenge_site_num': { | |
if(tnode.getAttribute('alt') == 'site_number'){ | |
SiteNumElement.check(tnode, area); | |
evt.stopPropagation(); break; | |
}else if(tnode.parentNode.getAttribute('alt') == 'site_number'){ | |
SiteNumElement.check(tnode.parentNode, area); | |
evt.stopPropagation(); break; | |
}else break; | |
} | |
case 'relookup': { | |
FluJE.showResult(str, [parseInt(tnode.name, 10)]); break; | |
} | |
default: break; | |
} | |
}, false); | |
root.appendChild($N('div', {style:'clear:both !important;'})); | |
pNode.insertBefore(root, pNode.firstChild); | |
return root; | |
} | |
} | |
//----------------------------------------------------------------------------- | |
// Quick Lookup | |
//----------------------------------------------------------------------------- | |
var QLu = { | |
loaded: false, | |
initCSS: function() { | |
var id1 = 'div#FluJE_quick_lookup', id2 = id1+' input#FluJE_quick_lookup_input'; | |
var inherit = 'background: inherit; background-image: inherit; background-color: inherit; color: inherit; text-align: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; margin: inherit; text-decoration: inherit; border: 0px; height: auto; padding: 0; font-family: inherit; vertical-align: inherit; line-height: inherit; font-stretch: inherit; font-variant: inherit; font-size-adjust: inherit; letter-spacing: inherit;'; | |
var css = [ id1,'{ background: #000; background-image: none; background-color: #000; color: #FFF; text-align: center; font-size: 15px; font-style: normal; font-weight: normal; margin: 0; text-decoration: none; border: 0px; padding: 0; font-family: inherit; vertical-align: middle; line-height: 100%; font-stretch: normal; font-variant: normal; font-size-adjust: none; letter-spacing: normal; z-index: 10000; height: 40px; position: fixed; left: 10px; right: 10px; bottom: 51%; padding-top: 20px; opacity: 0; -moz-border-radius: 10px; }\n', | |
id1,' span{ ',inherit,' margin-right: 10px; font-weight: bold; }\n', | |
id2,'{ ',inherit,' padding-left: 3px; padding-top: 2px; height: 20px; width: 85%; background-color: #FFF; color: #333; text-align: left; }\n' | |
].join(''); | |
return css; | |
}, | |
close: function(elm) { | |
$('FluJE_quick_lookup_input').blur(); | |
Effect.fadeio(elm); | |
}, | |
createNode: function(){ | |
var self = this; | |
var title = $N('span', null, 'Quick Lookup:'); | |
var input = $N('input', {id:'FluJE_quick_lookup_input'}); | |
var div = document.body.appendChild($N('div', {id:'FluJE_quick_lookup'}, [title, input])); | |
//== Event == | |
div.addEventListener('click', function(e){ | |
if(e.target != input) | |
self.close(div); | |
}, false); | |
input.addEventListener('focus', function(){ | |
input.style.backgroundColor = "#FFFFFF"; | |
},false); | |
input.addEventListener('blur', function(){ | |
input.style.backgroundColor = "#CCCCCC"; | |
},false); | |
ShortcutKey.add(input, 'RET', function(evt){ | |
switch(evt.target.value){ | |
case 'exit': { self.close(div); return; } | |
case '': { FluJE.removeResult(); break;} | |
default: FluJE.removeResult(); break; | |
} | |
FluJE.showResult(input.value); | |
}); | |
return div; | |
}, | |
run: function() { | |
var self = QLu; | |
if($('FluJE_quick_lookup')){ | |
Effect.fadeio($('FluJE_quick_lookup'), function(){ | |
$('FluJE_quick_lookup_input').select(); | |
}); | |
return; | |
} | |
if(loadStyle(self.loaded, self.initCSS(), self.run)){ | |
self.loaded = true; | |
return; | |
} | |
var div = self.createNode(); | |
Effect.fadeio(div, function(){ | |
$('FluJE_quick_lookup_input').select(); | |
}); | |
} | |
} | |
//----------------------------------------------------------------------------- | |
// SETTING CONTROL | |
//----------------------------------------------------------------------------- | |
var Setting = { | |
_default: DefaultSettings(), | |
save: function() { | |
GM_setValue('settings', SETTINGS.toSource()); | |
}, | |
load: function(){ | |
try { | |
var s = eval(GM_getValue('settings')); | |
if(s.ver && s.ver == VERSION){ | |
SETTINGS = s; | |
return 1; | |
} | |
} catch(e) {} | |
Setting.reset(); | |
SETTINGS = this._default; | |
this.save(); | |
return 0; | |
}, | |
reset: function(args){ | |
switch(typeof args){ | |
case 'object': { | |
for(var i in args){ | |
var type = typeof args[i]; | |
if(type == 'object'){ | |
this.set(args[i], "default", false); | |
}else if(type == 'string'){ | |
this.set(args, "default", false); break; | |
}else { break; } | |
} | |
break; | |
} | |
case 'string': { this.set(args, "default", false); break; } | |
case 'undefined': { this.set(); break; } | |
default: break; | |
} | |
this.save(); | |
}, | |
set: function(name, value, bool){ | |
var d = this._default; | |
switch(typeof name){ | |
case 'object': { | |
if(name.length <= 2){ | |
if(value=='default') | |
(name.length===1) ? value = d[name[0]] : value = d[name[0]][name[1]]; | |
(name.length===1) ? SETTINGS[name[0]] = value : SETTINGS[name[0]][name[1]] = value; | |
}else { | |
var str = ""; | |
for(var n in name) | |
str += "[\'"+name[n]+"\']"; | |
if(value=="default") | |
value = eval("Setting._default" + str); | |
str = "SETTINGS" + str; | |
str += (typeof value == 'string') ? "=\'"+value.toString()+"\'" : "="+value.toString(); | |
eval(str); | |
} | |
break; | |
} | |
case 'string': { SETTINGS[name] = value; break; } | |
case 'undefined': { SETTINGS = this._default; break; } | |
default: break; | |
} | |
if(bool!=false){ this.save(); } | |
}, | |
setSite: function(lang, num, param, modifier_key){ | |
var n = null; | |
var sites = SITEINFO; | |
var t = sites[num].type; | |
var s = (t == 'dictionary' || t == 'search') ? 'lookup' : 'translation'; | |
if (!SETTINGS[s]) | |
SETTINGS = Setting._default; | |
n = SETTINGS[s]; | |
var lookup_type = (lang=='ja') ? 'ja_type' : 'en_type'; | |
if(param){ | |
if(modifier_key) | |
n[lang].unshift(num); | |
else | |
n[lang].push(num); | |
if(t=='dictionary'){ | |
if(!n[lookup_type]) n[lookup_type] = t; | |
}else if(t=='search'){ | |
n[lookup_type] = t; | |
} | |
}else{ | |
n[lang] = this.delArray(n[lang], num); | |
if(t == 'search'){ | |
var ck_search = false; | |
for(var i in n[lang]){ | |
if(sites[i].type == 'search'){ | |
ck_search = true; break; | |
} | |
n[lookup_type] = (ck_search) ? 'search' : 'dictionary'; | |
} | |
} | |
} | |
this.save(); | |
}, | |
delArray: function(array, num){ | |
var a = 0, b = null; | |
array.forEach(function(e){ | |
if(e==num){ | |
b = a; | |
} | |
a++; | |
}); | |
var array_new = new Array(); | |
array_new = array.slice(0,b); | |
for(var i = b;i<array.length-1;i++){ | |
array_new[i] = array[i+1]; | |
} | |
return array_new; | |
}, | |
} | |
//----------------------------------------------------------------------------- | |
// Shortcut Key | |
//----------------------------------------------------------------------------- | |
var ShortcutKey = { | |
sp: { | |
9: 'TAB', | |
27: 'ESC', | |
33: 'PageUp', | |
34: 'PageDown', | |
35: 'End', | |
36: 'Home', | |
37: 'Left', | |
38: 'Up', | |
39: 'Right', | |
40: 'Down', | |
45: 'Insert', | |
46: 'Delete', | |
112: 'F1', | |
113: 'F2', | |
114: 'F3', | |
115: 'F4', | |
116: 'F5', | |
117: 'F6', | |
118: 'F7', | |
119: 'F8', | |
120: 'F9', | |
121: 'F10', | |
122: 'F11', | |
123: 'F12' | |
}, | |
ssp: { | |
8: 'BS', | |
10: 'RET', | |
13: 'RET', | |
32: 'SPC' | |
}, | |
add: function(elm, key, func, global) { | |
var sp = this.sp, ssp = this.ssp; | |
var keycode; | |
var m = []; | |
if(key) { | |
var keys = key.split(' '); | |
var position = 0; | |
var num = keys.length-1; | |
keys[position].replace(/^(?:([ACMS]{1,3})-)?(\w+)$/, function($0, $1, $2, $3) { | |
for(var i=0; i<$1.length; i++){ | |
var x = $1.charAt(i); | |
m.push(({ | |
C: "ctrl", | |
S: "shift", | |
A: "alt", | |
M: "meta" | |
})[x] + "Key"); | |
} | |
keycode = $2; | |
}); | |
elm.addEventListener('keypress', function(evt) { | |
var kc = ''; | |
if(evt.which) | |
kc = ssp[evt.which] || String.fromCharCode(evt.which).toLowerCase(); | |
else kc = sp[evt.keyCode]; | |
if(m.length) { | |
if((evt[m[0]] && (m[1]==undefined ? true : evt[m[1]]) && (m[2]==undefined ? true : evt[m[2]])) && kc==keycode) { | |
func(evt); | |
} | |
} else { | |
if(kc==keycode && !evt.shiftKey && !evt.altKey && !evt.ctrlKey && !evt.metaKey) { | |
if(global) func(evt); | |
else if(elm!=evt.target && /^(?:input|textarea)$/.test(evt.target.nodeName.toLowerCase())) return; | |
evt.preventDefault(); | |
func(evt); | |
} | |
} | |
}, false); | |
} else { | |
elm.addEventListener('keypress', func, false); | |
} | |
}, | |
get: function(elm, func) { | |
var sp = this.sp, ssp = this.ssp; | |
elm.addEventListener('keypress',function(evt){ | |
var key = []; | |
if(evt.ctrlKey) key.push('C'); | |
if(evt.shiftKey) key.push('S'); | |
if(evt.altKey) key.push('A'); | |
if(evt.metaKey) key.push('M'); | |
if(evt.ctrlKey || evt.shiftKey || evt.altKey || evt.metaKey) key.push('-'); | |
if(evt.which){ | |
var k = ssp[evt.which] || String.fromCharCode(evt.which).toLowerCase(); | |
key.push(k); | |
}else if(evt.keyCode){ | |
key.push(sp[evt.keyCode]); | |
} | |
if(key.length!=0) | |
func(evt, key.join('')); | |
evt.preventDefault(); | |
evt.stopPropagation(); | |
}, true); | |
}, | |
set: function(elm, sc_name, sc_index) { | |
this.get(elm, function(e, key){ | |
if(key=="ESC"){ | |
setTimeout(function(){ elm.value = key.toString(); }, 100); | |
}else{ | |
elm.value = key.toString(); | |
} | |
if(sc_name=='site') | |
Setting.set(['shortcutkey','site', sc_index, 'shortcutkey'], key); | |
else | |
Setting.set(['shortcutkey',sc_name], key); | |
elm.style.backgroundColor = '#CFC'; | |
setTimeout(function(){ elm.style.backgroundColor='#FFF'; }, 500); | |
}); | |
}, | |
} | |
var checkInputLang = function(num, lang){ | |
var site_lang = SITEINFO[num].lang; | |
switch(SITEINFO[num].lang) { | |
case 'both': return true; | |
case lang: return true; | |
default: return false; | |
} | |
} | |
//=== control number of sites === | |
var SiteNumElement = { | |
get: function(num, lang, format) { | |
var n = null; | |
var t = SITEINFO[num].type; | |
var s = (t == 'dictionary' || t == 'search') ? 'lookup' : 'translation'; | |
if(SETTINGS[s][lang]) | |
n = SETTINGS[s][lang]; | |
else { | |
var d = Setting._default; | |
n = d[s][lang]; | |
} | |
for(var i=0; i<n.length; i++){ | |
if(n[i]==num){ | |
if(format=='html') return "<span class='FluJE_site_number' title="+SITEINFO[i].name+" name="+num+" param='true' state='enable' evt='chenge_site_num'>"+(i+1).toString()+"</span>"; | |
else return $N('span', {class:'FluJE_site_number', title:SITEINFO[num].name, name: num, param: 'true', state:'enable', evt: 'chenge_site_num' }, (i+1).toString()); | |
} | |
} | |
if(checkInputLang(num, lang)){ | |
if(format=='html') return "<img class='FluJE_site_number' title="+SITEINFO[num].name+" name="+num+" param='false' state='enable' evt='chenge_site_num' src=\'"+IMAGES.o+"\'>"; | |
else return $N('img', {class:'FluJE_site_number', title:SITEINFO[num].name, name: num, param: 'false', state:'enable', evt: 'chenge_site_num', src:IMAGES.o}); | |
} | |
if(format=='html') return "<img class='FluJE_site_number' title="+SITEINFO[num].name+" name="+num+" param='false' state='disable' evt='chenge_site_num' src=\'"+IMAGES.x+"\'>"; | |
else return $N('img', {class:'FluJE_site_number', title:SITEINFO[num].name, name: num, param: 'false', state:'disable', evt: 'chenge_site_num', src:IMAGES.x}); | |
}, | |
replace: function(list, args, self, modifier_key) { | |
var lang = args.lang, sort = args.sort; | |
if(self){ | |
var elm = self.firstChild; | |
if(elm.getAttribute('state')=='disable') return; | |
Setting.setSite(lang, parseInt(elm.getAttribute('name'), 10), !eval(elm.getAttribute('param')), modifier_key); | |
} | |
var num = list.length; | |
for(var i=0; i<num; i++){ | |
if(list[i]){ | |
var id = list[i].getAttribute('site_id'); | |
if(list[i].hasChildNodes()) | |
list[i].removeChild(list[i].firstChild); | |
list[i].appendChild(this.get(parseInt(id, 10), lang)); | |
} | |
} | |
}, | |
check: function(tnode, pnode, modifier_key) { | |
if(tnode.getAttribute('state')!='enable') return; | |
tnode.getAttribute('name').match(/^([^:]+):(.*)$/); | |
var lang = RegExp.$1; | |
var type = RegExp.$2; | |
var sort = (type == 'translation') ? 'translation' : 'lookup'; | |
var node_list = $X('.//td[@class=\"FluJE_site_num_'+lang+'\"][@sort=\"'+sort+'\"]', pnode); | |
this.replace(node_list, {lang:lang, sort:sort}, tnode, modifier_key); | |
}, | |
} | |
var getIcon = function(num){ | |
if(num==undefined || SITEINFO.length<num) | |
return; | |
if(SITEINFO[num].icon) | |
return SITEINFO[num].icon; | |
else | |
return SITEINFO[num].url.match(new RegExp('http://[^/]+/', "i"))+'favicon.ico'; | |
} | |
//=== load Fast look up JP and EN === | |
if(document.body){ FluJE.onLoad(); } | |
//----------------------------------------------------------------------------- | |
// Library | |
//----------------------------------------------------------------------------- | |
//=== load CSS === | |
function loadStyle(flag, css, func) { | |
if(flag) | |
return false; | |
if(css) | |
addStyle(css); | |
if(func) { | |
setTimeout(func, 100); | |
return true; | |
} | |
} | |
//=== log for debug (display in firebug) === | |
function log() { | |
if(console) console.log.apply(console, Array.slice(arguments)); | |
} | |
//=== in place of gm_addstyle === | |
function addStyle(css,id) { | |
try{ | |
var link = document.createElement('link'); | |
link.rel = 'stylesheet'; | |
link.href = 'data:text/css,' + escape(css); | |
document.documentElement.childNodes[0].appendChild(link); | |
}catch(e){ | |
if(css) GM_addStyle(css); | |
} | |
} | |
//=== Escape Encoding === | |
function EscapeEncoding(type, str){ | |
switch(type){ | |
case 'EUC-JP': return EscapeEUCJP(str); | |
case 'Shift_JIS': return EscapeSJIS(str); | |
case 'UTF-8': return EscapeUTF8(str); | |
default: return str; | |
} | |
} | |
JCT11280=Function('var a="zKV33~jZ4zN=~ji36XazM93y!{~k2y!o~k0ZlW6zN?3Wz3W?{EKzK[33[`y|;-~j^YOTz$!~kNy|L1$353~jV3zKk3~k-4P4zK_2+~jY4y!xYHR~jlz$_~jk4z$e3X5He<0y!wy|X3[:~l|VU[F3VZ056Hy!nz/m1XD61+1XY1E1=1y|bzKiz!H034zKj~mEz#c5ZA3-3X$1~mBz$$3~lyz#,4YN5~mEz#{ZKZ3V%7Y}!J3X-YEX_J(3~mAz =V;kE0/y|F3y!}~m>z/U~mI~j_2+~mA~jp2;~m@~k32;~m>V}2u~mEX#2x~mBy+x2242(~mBy,;2242(~may->2&XkG2;~mIy-_2&NXd2;~mGz,{4<6:.:B*B:XC4>6:.>B*BBXSA+A:X]E&E<~r#z+625z s2+zN=`HXI@YMXIAXZYUM8X4K/:Q!Z&33 3YWX[~mB`{zKt4z (zV/z 3zRw2%Wd39]S11z$PAXH5Xb;ZQWU1ZgWP%3~o@{Dgl#gd}T){Uo{y5_d{e@}C(} WU9|cB{w}bzvV|)[} H|zT}d||0~{]Q|(l{|x{iv{dw}(5}[Z|kuZ }cq{{y|ij}.I{idbof%cu^d}Rj^y|-M{ESYGYfYsZslS`?ZdYO__gLYRZ&fvb4oKfhSf^d<Yeasc1f&a=hnYG{QY{D`Bsa|u,}Dl|_Q{C%xK|Aq}C>|c#ryW=}eY{L+`)][YF_Ub^h4}[X|?r|u_ex}TL@YR]j{SrXgo*|Gv|rK}B#mu{R1}hs|dP{C7|^Qt3|@P{YVV |8&}#D}ef{e/{Rl|>Hni}R1{Z#{D[}CQlQ||E}[s{SG_+i8eplY[=[|ec[$YXn#`hcm}YR|{Ci(_[ql|?8p3]-}^t{wy}4la&pc|3e{Rp{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]%}^LZwZQ5Z`/OT<Yh^ -~]&}jx[ ~m<z!%2+~ly4VY-~o>}p62yz!%2+Xf2+~ly4VY-zQ`z (=] 2z~o2",C={" ":0,"!":1},c=34,i=2,p,s="",u=String.fromCharCode,t=u(12539);while(++c<127)C[u(c)]=c^39&&c^92?i++:0;i=0;while(0<=(c=C[a.charAt(i++)]))if(16==c)if((c=C[a.charAt(i++)])<87){if(86==c)c=1879;while(c--)s+=u(++p)}else s+=s.substr(8272,360);else if(c<86)s+=u(p+=c<51?c-16:(c-55)*92+C[a.charAt(i++)]);else if((c=((c-86)*92+C[a.charAt(i++)])*92+C[a.charAt(i++)])<49152)s+=u(p=c<40960?c:c|57344);else{c&=511;while(c--)s+=t;p=12539}return s')(); | |
JCT8836=JCT11280.substring(0,8836); | |
function EscapeEUCJP(str){ | |
return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){ | |
var c=s.charCodeAt(0); | |
return (c<128?(c<16?"%0":"%")+c.toString(16):65376<c&&c<65440?"%8E%"+(c-65216).toString(16):(c=JCT8836.indexOf(s))<0?"%A1%A6":"%"+((c-(c%=94))/94+161).toString(16)+"%"+(c+161).toString(16)).toUpperCase() | |
}) | |
}; | |
function EscapeSJIS(str){ | |
return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){ | |
var c=s.charCodeAt(0),m; | |
return c<128?(c<16?"%0":"%")+c.toString(16).toUpperCase():65376<c&&c<65440?"%"+(c-65216).toString(16).toUpperCase():(c=JCT11280.indexOf(s))<0?"%81E":"%"+((m=((c<8272?c:(c=JCT11280.lastIndexOf(s)))-(c%=188))/188)<31?m+129:m+193).toString(16).toUpperCase()+(64<(c+=c<63?64:65)&&c<91||95==c||96<c&&c<123?String.fromCharCode(c):"%"+c.toString(16).toUpperCase()) | |
}) | |
}; | |
function EscapeUTF8(str){ | |
return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){ | |
var c=s.charCodeAt(0); | |
return (c<16?"%0"+c.toString(16):c<128?"%"+c.toString(16):c<2048?"%"+(c>>6|192).toString(16)+"%"+(c&63|128).toString(16):"%"+(c>>12|224).toString(16)+"%"+(c>>6&63|128).toString(16)+"%"+(c&63|128).toString(16)).toUpperCase() | |
}) | |
}; | |
//=== like prototype.js === | |
function $(id){ | |
return document.getElementById(id); | |
} | |
function $N(name, attr, childs) { | |
var ret = document.createElement(name); | |
for (var k in attr) { | |
if (!attr.hasOwnProperty(k)) continue; | |
v = attr[k]; | |
if (k == "class") { | |
ret.className = v; | |
} else { | |
ret.setAttribute(k, v); | |
} | |
} | |
switch (typeof childs) { | |
case "string": { | |
ret.appendChild(document.createTextNode(childs)); | |
break; | |
} | |
case "object": { | |
for (var i = 0, len = childs.length; i < len; i++) { | |
var child = childs[i]; | |
if (typeof child == "string") { | |
ret.appendChild(document.createTextNode(child)); | |
} else { | |
ret.appendChild(child); | |
} | |
} | |
break; | |
} | |
} | |
return ret; | |
} | |
//=== extend version of $X === | |
/* $X(exp); | |
$X(exp, context); | |
$X(exp, type); | |
$X(exp, context, type); | |
http://coderepos.org/share/browser/lang/javascript/userscripts/jautopagerize.user.js?rev=1966 */ | |
function $X (exp, context, type /* want type */) { | |
if (arguments.callee.forceRelative || navigator.userAgent.indexOf("Safari/523.12") != -1) | |
exp = exp.replace(/id\(\s*(["'])([^"']+)\1\s*\)/g, '//*[@id="$2"]'); | |
if (arguments.callee.forceRelative) | |
exp = exp.indexOf("(//") == 0 | |
? "(.//" + exp.substring(3) | |
: (exp[0] == "/" ? "." : "./") + exp; | |
if (typeof context == "function") { | |
type = context; | |
context = null; | |
} | |
if (!context) context = document; | |
exp = (context.ownerDocument || context).createExpression(exp, function (prefix) { | |
return document.createNSResolver((context.ownerDocument == null ? context | |
: context.ownerDocument).documentElement) | |
.lookupNamespaceURI(prefix) || document.documentElement.namespaceURI; | |
}); | |
switch (type) { | |
case String: | |
return exp.evaluate(context, XPathResult.STRING_TYPE, null).stringValue; | |
case Number: | |
return exp.evaluate(context, XPathResult.NUMBER_TYPE, null).numberValue; | |
case Boolean: | |
return exp.evaluate(context, XPathResult.BOOLEAN_TYPE, null).booleanValue; | |
case Array: | |
var result = exp.evaluate(context, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
var ret = []; | |
for (var i = 0, len = result.snapshotLength; i < len; i++) { | |
ret.push(result.snapshotItem(i)); | |
} | |
return ret; | |
case undefined: | |
var result = exp.evaluate(context, XPathResult.ANY_TYPE, null); | |
switch (result.resultType) { | |
case XPathResult.STRING_TYPE : return result.stringValue; | |
case XPathResult.NUMBER_TYPE : return result.numberValue; | |
case XPathResult.BOOLEAN_TYPE: return result.booleanValue; | |
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: { | |
/* not ensure the order. */ | |
var ret = []; | |
var i = null; | |
while (i = result.iterateNext()) { | |
ret.push(i); | |
} | |
return ret; | |
} | |
} | |
return null; | |
default: | |
throw(TypeError("$X: specified type is not valid type.")); | |
} | |
} | |
//=== HTML -> DOM === | |
function convertToHTMLDocument(html) { | |
var xml_str = [ | |
'<?xml version="1.0"?>', | |
'<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">', | |
'<output method="html"/>', | |
'</stylesheet>' | |
].join('\n'); | |
var xsl = (new DOMParser()).parseFromString(xml_str, 'text/xml'); | |
var xsltp = new XSLTProcessor(); | |
xsltp.importStylesheet(xsl); | |
var doc = xsltp.transformToDocument(document.implementation.createDocument("", "", null)); | |
doc.appendChild(doc.createElement("html")); | |
var range = doc.createRange(); | |
range.selectNodeContents(doc.documentElement); | |
doc.documentElement.appendChild(range.createContextualFragment(html)); | |
return doc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SITEINFO↓ので動いてるんだけど、wedataから取ってくると動いてないような。
{
name: "ExciteTT",
url: "http://www.excite.co.jp/world/english/",
method :"POST",
space : "+",
data : "before=[context]&wb_lp=ENJA",
icon: "data:image/gif;base64,R0lGODlhEAAQALMAAAQCBISCBIQCBPz+/PwCBAfO0JUSEnwAAAvu0AAUUQDEHQAAAJjJAAgDAKIBAAAAACH5BAAAAAAALAAAAAAQABAAAwQ3cMhJq6XkziwDH9/GEZy3nWAghWRnqRi8upewtoA25OCuSzwB7wco/iZC21FoJBqbGij06JtEAAA7",
xpath: "id('after')/text()",
lang: "en",
type: "translation",
enc: "UTF-8"
},