Last active
August 29, 2015 13:58
-
-
Save bluelovers/9950551 to your computer and use it in GitHub Desktop.
GW2 Plus
This file contains hidden or 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 GW2 Plus | |
// @namespace http://use.i.E.your.homepage/ | |
// @version 0.1 | |
// @grant none | |
// @description enter something useful | |
// @include http*://gw2zh.com/* | |
// @include http*://us.gw2stuff.com/*/events/* | |
// @include http*://www.gw2spidy.com/* | |
// @include http*://wiki.guildwars2.com/* | |
// @include http*://www.gw2crafts.net/*.html | |
// @include http*://divinitysreach.com/map/en/*/ | |
// @include http*://tradingpost-*.ncplatform.net/* | |
// @include http*://dulfy.net/* | |
// @include http*://forum-*.guildwars2.com/* | |
// @exclude *.js* | |
// @exclude *.css* | |
// @copyright 2012+, You | |
// @require http://code.jquery.com/jquery-latest.js?KU201 | |
// @require https://gist.github.com/bluelovers/5046969/raw/UserScript%20Framework.js?KU202 | |
// @require https://raw.github.com/Sjeiti/TinySort/master/src/jquery.tinysort.js?KU202 | |
// ==/UserScript== | |
(function($){$(function(){ | |
var unsafeWindow = unsafeWindow || window; | |
var _url = window.location.href; | |
var _url_obj = parse_url(_url); | |
var _url_host = _url_obj.host; | |
GM_addStyle('@import url(https://d1h9a8s8eodvjz.cloudfront.net/fonts/menomonia/08-02-12/menomonia.css); @import url(https://d1h9a8s8eodvjz.cloudfront.net/fonts/menomonia/08-02-12/menomonia-italic.css);'); | |
if (_url_host.match(/gw2zh\.com/)) | |
{ | |
GM_addStyle('html, body, table { font-family: Helvetica,Arial,sans-serif; }'); | |
if ($('#p-lang .interwiki-en').size()) | |
{ | |
var _langs = $('#p-lang .body ul'); | |
} | |
else | |
{ | |
var _langs = $('<ul/>').appendTo($('<div class="body"/>').appendTo($('<div id="p-lang" class="portal"/>').append($('<h5>Other languages</h5>')).appendTo($('#column-one, #mw-panel').eq(0)))); | |
_langs.append($('<li class="interwiki-en"/>').append($('<a style="color: red;"/>').attr('href', _url.replace('http://gw2zh.com/zh/', 'http://wiki.guildwars2.com/wiki/').replace('http://gw2zh.com/', 'http://wiki.guildwars2.com/')).text('English'))); | |
} | |
_mw_plus(); | |
$('#mw-search-top-table input:submit').eq(0).after($('<input type="button" value="Search on GW2W"/>').click(function(){ | |
_gw2w_search($('#searchText').val()); | |
})); | |
} | |
else if (_url_host.match(/gw2spidy\.com/)) | |
{ | |
GM_addStyle('.rarity-rare, .db-tooltip.p-tooltip_gw2 .gwitem-rare, .db-tooltip.p-tooltip_gw2 .gwitem-rare a, .db-tooltip.p-tooltip_gw2 .gwrecipe-rare, .db-tooltip.p-tooltip_gw2 .gwrecipe-rare a { color: #FFFF00!important; }'); | |
GM_addStyle('.item-row-wrapper .item-row, .item-list-table .item:nth-child(odd) td { background: #112 url("../img/tooltip/bg_tooltip2.png"); }'); | |
GM_addStyle('.item-list-table .item:nth-child(even) td { background: #1B0F49; }') | |
GM_addStyle('.item-list-table .item:hover td { background: #28075A !important; }'); | |
GM_addStyle('.rarity-common, .item-row-wrapper .item-row, .item-list-table .item { color: #fff !important; }'); | |
$('.p-tooltip_gw2').on('click', '.db-description .db-summary .db-title', function(){ | |
_gw2w_search($(this).text()); | |
}); | |
$('.navbar-search, .form-search').on('change', 'input.search-query', function(){ | |
$(this).val(_trim_gw2($(this).val())); | |
}); | |
$('.item-list-table .item .info a.name').attr('target', '_blank'); | |
} | |
else if (_url_host.match(/wiki\.guildwars2\.com/)) | |
{ | |
if ($('#p-lang .pBody ul:eq(0)').size()) | |
{ | |
var _langs = $('#p-lang .pBody ul'); | |
} | |
else | |
{ | |
var _langs = $('<ul/>').appendTo($('<div class="pBody"/>').appendTo($('<div id="p-lang" class="portlet"/>').append($('<h5>Other languages</h5>')).appendTo($('#column-one')))); | |
} | |
_langs.append($('<li class="interwiki-zh"/>').append($('<a/>').attr('href', _url.replace('http://wiki.guildwars2.com/wiki/', 'http://gw2zh.com/zh/').replace('http://wiki.guildwars2.com/', 'http://gw2zh.com/')).text('Chinese'))); | |
_mw_plus(); | |
} | |
else if (_url_host.match(/gw2crafts\.net/)) | |
{ | |
GM_addStyle('span.itemIcon, gi { vertical-align: text-bottom; }'); | |
$('.Fine, .Basic, .Exotic, .Masterwork, .Rare').each(function(){ | |
var _this = $(this); | |
_this.after($('<img class="gi" src="http://www.gw2spidy.com/assets/v20131010v2/img/favicon.ico" height="16"/ alt="gw2spidy" style="vertical-align: middle; margin-left: 5px;">').click(function(){ | |
_gw2spidy_search(_this.text()); | |
})).after($('<img class="gi" src="http://wiki.guildwars2.com/favicon.ico" height="16"/ alt="gw2w" style="vertical-align: middle; margin-left: 5px;">').click(function(){ | |
_gw2w_search(_this.text()); | |
})); | |
}); | |
$('#show_all:first').trigger('click'); | |
var _main = $('section.main:first'); | |
var _i, _id; | |
_main.find('h3:first').nextAll('h3, div').andSelf().each(function(){ | |
var _this = $(this); | |
var _text = _this.text(); | |
if (_this.is('h3')) | |
{ | |
if (_id && _i) | |
{ | |
$('h3#' + _id).append($('<span/>').text('Discover: ' + _i).css('margin-left', 20)); | |
} | |
_i = 0; | |
_id = _text.replace(/[^a-zA-Z0-9]/, '').replace(/\s+/, ''); | |
_this.attr('id', _id); | |
} | |
else if (_this.is('div')) | |
{ | |
if (_text.match(/Discover\:/)) | |
{ | |
_i++; | |
} | |
} | |
}); | |
} | |
else if (_url_host.match(/divinitysreach\.com/)) | |
{ | |
//unsafeWindow.document.eventMetaData | |
$(unsafeWindow).on('load', function(){ | |
var require = unsafeWindow.require; | |
//console.log(require); | |
var _filter = $.extend({}, { | |
'filter-play-alerts' : true, | |
'filter-speak-alerts' : true, | |
'filter-active-events' : true, | |
'filter-preparing-events' : true | |
}, localStorage.getItem("filter")); | |
_uf_loop(function(){ | |
return $('#filter-speak-alerts').size(); | |
}, function(){ | |
var chestevents = require.config('chestevents'); | |
//console.log(chestevents); | |
chestevents = $.extend(chestevents, { | |
'5E4E9CD9-DD7C-49DB-8392-C99E1EF4E7DF' : 'fireele', | |
//'BA43EBDF-9276-4155-8A7B-03A58D621211' : 'balthazar', | |
'D3FFC041-4124-4AA7-A74B-B9363ED1BCBD' : 'balthazar', | |
'A8D1A2B7-1F1B-413D-8E64-06CA0D26712D' : 'balthazar', | |
'45B84A62-BE33-4371-B9FB-CC8490528276' : 'balthazar', | |
'A0E5E563-2701-4D4E-8163-A89FEA02EC38' : 'eyeofzhaitan', | |
/* | |
'4920CE71-833B-4DF9-B9C4-6881C50F64C8' : 'eyeofzhaitan', | |
*/ | |
'E8151970-27A3-4BE3-8EE0-17535A8A5D7D' : 'megadestroyer', | |
'3BA29A69-A30B-405D-96AC-CBA5D511C163' : 'megadestroyer', | |
'294E08F6-CA36-42B3-8D06-B321BA06EECA' : 'megadestroyer', | |
'9E5D9F1A-FE14-49C6-917F-43AAE227165C' : 'megadestroyer', | |
'584A4D22-33DC-4D77-A5D9-2FA7379401ED' : 'megadestroyer', | |
'4210CE81-BDB7-448E-BE33-46E18A5A3477' : 'megadestroyer', | |
//'2D3EB570-FD60-44F0-BB59-3A05DF9242D0' : 'battleforlionsarch', | |
'A33D79C7-64CF-44BE-9D67-E50523A81F3E' : 'battleforlionsarch', | |
//'D52DFC92-3324-4A7F-BF3C-6D455832BCFF' : 'battleforlionsarch', | |
//'91A6B7DF-D5C2-49A0-B583-277EB668A636' : 'battleforlionsarch', | |
'51B94A51-5883-4DBC-9BFE-294AD6B84EDE' : 'battleforlionsarch', | |
//'4A1DECF3-C1AD-42EC-9905-976B281CFA49' : 'ulgoth', | |
'AE7AAA0C-5619-4C94-918B-6022DB9AA481' : 'ulgoth', | |
'38E99B3A-C4E5-4F1E-B5B9-24DD3DF5EDB4' : 'ulgoth', | |
'C3A1BAE2-E7F2-4929-A3AA-92D39283722C' : 'ulgoth', | |
'F531683F-FC09-467F-9661-6741E8382E24' : 'dwayna', | |
'7EF31D63-DB2A-4FEB-A6C6-478F382BFBCB' : 'dwayna', | |
'C2AB5C4C-5FAA-449B-985C-93F8E2D579C8' : 'grenth', | |
'B41C90F8-AF33-400E-9AD3-3DB0AFCEDC6C' : 'grenth', | |
'4B612C93-3700-43B8-B3C1-CBC64FEC0566' : 'grenth', | |
'1D1BE3D6-2F0D-4D1C-8233-812AAF261CFF' : 'grenth', | |
'3D333172-24CE-47BA-8F1A-1AD47E7B69E4' : 'melandru', | |
'D7246CA2-DD85-42B3-A8D3-D2A1FE464ECF' : 'gatesofarah', | |
'80F7CC11-3116-42B5-A7C3-965EE5A69E51' : 'gatesofarah', | |
'5761F5A5-48D2-484B-BE21-22096E84E845' : 'gatesofarah', | |
'6B5C8659-F3AF-4DFC-A6F5-CD6620E3BE11' : 'gatesofarah', | |
'E87A021D-4E7C-4A50-BEDB-6F5A54C90A9A' : 'gatesofarah' | |
}); | |
//console.log(_filter); | |
//$('#filter-play-alerts, #filter-speak-alerts, #filter-active-events, #filter-preparing-events, #filter-waypoint') | |
$('#filter-play-alerts, #filter-speak-alerts') | |
.each(function(){ | |
var _this = $(this); | |
//console.log(_this.attr('id') + ' : ' + _this.is(':checked') + ' : ' + _filter[_this.attr('id')]); | |
if (_this.is(':checked') != _filter[_this.attr('id')]) | |
{ | |
_this.trigger('click'); | |
} | |
//_this.prop("checked", _filter[_this.attr('id')]).triggerHandler('notification:optionschanged'); | |
}) | |
.on('change.localStorage', function(){ | |
var _this = $(this); | |
_filter[_this.attr('id')] = _this.is(':checked') ? true : false; | |
localStorage.setItem("filter", _filter); | |
}) | |
; | |
//console.log(chestevents['D7246CA2-DD85-42B3-A8D3-D2A1FE464ECF']); | |
//console.log(require.config('chestevents')['D7246CA2-DD85-42B3-A8D3-D2A1FE464ECF']); | |
//console.log(chestevents); | |
}, 500, 150); | |
}); | |
} | |
else if (_url_host.match(/tradingpost-live\.ncplatform\.net/)) | |
{ | |
GM_addStyle('body { background-color: rgb(36, 20, 8); }'); | |
unsafeWindow.$ = $; | |
} | |
else if (_url_host.match(/dulfy\.net/)) | |
{ | |
$('.post-content .easySpoilerWrapper .easySpoilerButton').trigger('click'); | |
} | |
else if (_url_host.match(/forum\-.+\.guildwars2\.com/)) | |
{ | |
$('.message-content a[href^="/external?l="]') | |
.attr('target', '_blank') | |
.each(function(){ | |
var _this = $(this); | |
_this.attr('href', decodeURIComponent(_this.attr('href').replace(/^\/external\?l=/, ''))); | |
}) | |
; | |
$('a.topic') | |
.attr('target', '_blank') | |
; | |
} | |
function _uf_loop(t, f, s, d) | |
{ | |
if (($.isFunction(t) && t()) || (!$.isFunction(t) && t)) | |
{ | |
//console.log('_uf_loop: true'); | |
if ($.isNumeric(d) && d > 0) | |
{ | |
setTimeout(f, d); | |
} | |
else | |
{ | |
f(); | |
} | |
} | |
else | |
{ | |
//console.log('_uf_loop: wait'); | |
setTimeout(function(){ | |
_uf_loop(t, f, s); | |
}, s); | |
} | |
} | |
function _mw_plus() | |
{ | |
$("form#searchform, form#search").submit(function(event) { | |
$(this).find('input#searchInput, input#searchText').trigger('change'); | |
}).find('input#searchInput, input#searchText').on('change, keyup, focusout', function(){ | |
$(this).val(function(idx, value){ | |
return _trim_gw2(value); | |
}) | |
}); | |
$('#p-lang .pBody ul, [class^="interwiki"]').find('a').attr('target', '_blank'); | |
} | |
function _is_eng(text) | |
{ | |
return text.match(/[^(\x20-\x7F)]*/) ? false : true; | |
} | |
function _uf_done(event) | |
{ | |
event.stopPropagation(); | |
event.preventDefault(); | |
} | |
function _trim_gw2(text) | |
{ | |
var _text = '' + text; | |
_text = _text | |
.replace(/^\[/, '') | |
.replace(/\]$/, '') | |
.replace(/^\d+ (\w+.+)s$/, '$1') | |
; | |
return _text; | |
} | |
function _gw2w_search(text) | |
{ | |
GM_openInTab('http://wiki.guildwars2.com/index.php?title=Special%3ASearch&profile=default&search=' + _trim_gw2(text)); | |
} | |
function _gw2spidy_search(text) | |
{ | |
GM_openInTab('http://www.gw2spidy.com/search/' + _trim_gw2(text)); | |
} | |
})})(jQuery.noConflict()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment