Skip to content

Instantly share code, notes, and snippets.

@Archomeda
Last active June 21, 2019 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Archomeda/57e6fd21d3006f607ed3187a85dac5e0 to your computer and use it in GitHub Desktop.
Save Archomeda/57e6fd21d3006f607ed3187a85dac5e0 to your computer and use it in GitHub Desktop.
// ==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