Skip to content

Instantly share code, notes, and snippets.

@amio
Created October 22, 2012 07:17
Show Gist options
  • Save amio/3930081 to your computer and use it in GitHub Desktop.
Save amio/3930081 to your computer and use it in GitHub Desktop.
WOL.CN
// ==UserScript==
// @name WOL.CN
// @namespace http://www.airmio.com/
// @version 0.1
// @description 将WOL中鼠标指向技能的英文说明替换为中文说明
// @match http://www.worldoflogs.com/*
// @update https://gist.github.com/raw/3930081/wolcn.user.js
// ==/UserScript==
(function(styleStr){
// inject google font
var wrapper = document.createElement('div');
wrapper.innerHTML = '<link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">';
document.querySelector('head').appendChild(wrapper.firstChild);
// inject style
wrapper.innerHTML = '<style type="text/css">' + styleStr + '</style>';
document.querySelector('head').appendChild(wrapper.firstChild);
})(
'#wrapper { font-family: "Open Sans", "Calibri", "Arial", sans-serif; }'
);
(function(func){
// inject func
var el = document.createElement('script');
el.innerHTML = '(' + func.toString() + ')()';
document.body.appendChild(el); // run the script
})(function(){
// fix armory link
var armoryLink = document.querySelectorAll('a[href^="http://cn.battle.net"]');
for(var i = armoryLink.length; i--; ){
armoryLink[i].href = armoryLink[i].href.replace('cn.battle.net','www.battlenet.com.cn')
}
/**
* Inject translation
*/
if(!$WowheadPower){
return;
}
function inject(script) {
var el = document.createElement('script');
el.setAttribute("type", "application/javascript");
el.setAttribute("src", script);
document.body.appendChild(el); // run the script
document.body.removeChild(el); // clean up
}
window.$178DB = {
'spells':{},
'regstSpell': function(cnSpellObj){
var currentSpell = $178DB.spells[cnSpellObj['id']];
//replace en tips with cn tips
currentSpell[2]['tooltip_enus'] = cnSpellObj['tip'];
//call the origin register
origReg.apply($WowheadPower,currentSpell);
}
};
var origReg = $WowheadPower.registerSpell;
$WowheadPower.registerSpell = function (id,zero,spellObj) {
var cnSpellJs = 'http://db.178.com/wow/cn/a/spell/{id}.js'.replace('{id}',id);
$178DB['spells'][id] = [id,zero,spellObj];
// OK, It's your turn now
inject(cnSpellJs);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment