User:Nefastu/JS/APILink.js
From Guild Wars 2 Wiki
Jump to navigationJump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
if($('div.infobox.item')[0] || $('div.infobox.weapon')[0] || $('div.infobox.armor')[0] || $('div.infobox.upgrade.component')[0]){ $apilink = "<dt title='Added via user javascript'>External links</dt><dd><a rel='nofollow' class='external text' href='https://api.guildwars2.com/v2/::TYPE::s?id=::ID::&lang=en'>API</a></dd>"; //get type and id $spellid = $('div.infobox span.gamelink').attr('title'); $spelltype = $('div.infobox span.gamelink').attr('data-type'); if(typeof $spelltype != "undefined" && typeof $spellid != "undefined"){ $apilink = $apilink.replace(/::TYPE::/, $spelltype); $apilink = $apilink.replace(/::ID::/, $spellid); $('div.infobox dd:last').after($apilink); } }