Last active
June 21, 2019 18:13
-
-
Save Archomeda/57e6fd21d3006f607ed3187a85dac5e0 to your computer and use it in GitHub Desktop.
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 Replace GW2 API icons on SnowCrows | |
// @namespace https://gist.github.com/Archomeda/57e6fd21d3006f607ed3187a85dac5e0 | |
// @version 1.0 | |
// @description Replaces various GW2 API icons on SnowCrows with a mirror (hosted by dev.gw2treasures.com/services/icons) | |
// @author Archomeda | |
// @match https://snowcrows.com/* | |
// @match https://www.snowcrows.com/* | |
// @grant none | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.slim.min.js | |
// @downloadURL https://gist.github.com/Archomeda/57e6fd21d3006f607ed3187a85dac5e0/raw/snowcrows-icons.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var $ = window.jQuery; | |
var imageRegex = /render\.guildwars2\.com\/file\/(.*)\.png/i; | |
var done = false; | |
function replace() { | |
var $images = $('div').each(function () { | |
var oldImage = $(this).css('background-image'); | |
var newImage = oldImage.replace(imageRegex, 'darthmaim-cdn.de/gw2treasures/icons/$1.png'); | |
if (oldImage !== newImage) { | |
console.log(`Replacing ${oldImage} with ${newImage}`); | |
$(this).css('background-image', newImage); | |
done = true; | |
} | |
}); | |
if (!done) { | |
setTimeout(replace, 1000); | |
} | |
} | |
replace(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment