siomi / Sneakersale Redirect

// ==UserScript==
// @name         Sneakersale Redirect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Strict privacy settings block trackers and sometimes break some sites. Sneakersale URL shortener is one of them, let's make it work the way we need.
// @author       siomi
// @license      MIT; https://spdx.org/licenses/MIT.html
// @match        https://snkr.sl/*
// @match        http://snkr.sl/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let scripts = document.querySelectorAll('script');
    let url = null;
    for(let i=0;i<scripts.length && url === null;i++) {
        let m = scripts[i].innerText.match(/window\.location\.replace\(["|'](http.+)["|']\);/);
        if(m !== null) { url = m[m.length-1]; }
    }
    if(url !== null) {
        window.location.replace(url);
    }
})();