Skip to content

Instantly share code, notes, and snippets.

@noromanba
Last active December 23, 2016 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save noromanba/6b83ef63fe8b794364267bd832fdbc71 to your computer and use it in GitHub Desktop.
Save noromanba/6b83ef63fe8b794364267bd832fdbc71 to your computer and use it in GitHub Desktop.
remove exit.sc redirector from links on SoundCloud for UserScript
// ==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