-
-
Save hachesilva/0dd08d471ae97cf8938d1851648fc374 to your computer and use it in GitHub Desktop.
remove exit.sc redirector from links on SoundCloud for UserScript
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 exit exit.sc | |
// @namespace http://noromanba.flavors.me | |
// @description remove exit.sc redirector from links on SoundCloud for UserScript | |
// @include https://soundcloud.com/* | |
// @grant none | |
// @noframes | |
// @run-at document-end | |
// @version 2016.6.8.1 | |
// @homepage https://gist.github.com/noromanba/6b83ef63fe8b794364267bd832fdbc71 | |
// @downloadURL https://gist.github.com/noromanba/6b83ef63fe8b794364267bd832fdbc71/raw/exit-exit-sc.user.js | |
// @contributor noromanba https://gist.github.com/noromanba/76a3d7791cf6eaf1c94c (Fork of) | |
// @license MIT License https://nrm.mit-license.org/2016 | |
// @author noromanba http://noromanba.flavors.me | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/New_Zealand_TW-12.svg/128px-New_Zealand_TW-12.svg.png | |
// ==/UserScript== | |
// Icon (PD by By New Zealand Transport Agency) | |
// https://commons.wikimedia.org/wiki/File%3ANew_Zealand_TW-12.svg | |
// http://www.nzta.govt.nz/resources/traffic-control-devices-manual/sign-specifications/ | |
// Devel | |
// https://gist.github.com/noromanba/6b83ef63fe8b794364267bd832fdbc71 | |
// e.g. | |
// https://soundcloud.com/coruscant | |
(() => { | |
'use strict'; | |
const detox = (ctx) => { | |
if (!ctx.querySelectorAll) return; | |
Array.from(ctx.querySelectorAll([ | |
'a[href^="https://exit.sc?url="]' | |
]), link => { | |
// redirector syntax; | |
// https://exit.sc?url=<ENCODED_URL> | |
const url = (new URL(link.href).search.match(/(?:\?|&)url=([^&]+)/) || [])[1]; | |
if (!url) return; | |
link.href = decodeURIComponent(url); | |
}); | |
}; | |
detox(document.body); | |
new MutationObserver(records => { | |
records.forEach(record => { | |
detox(record.target); | |
}); | |
}).observe(document.body, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment