Last active
December 6, 2022 19:22
-
-
Save ymolliks/3e89f1464830f39f9a0f9187e0e33e7d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Youtube shorts redirect | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Medium > Scribe.rip redirect | |
// @author Fuim | |
// @match *://*.medium.com/* | |
// @icon https://www.google.com/s2/favicons?domain=medium.com | |
// @grant none | |
// @run-at document-start | |
// @license GNU GLPv2 | |
// ==/UserScript== | |
var oldHref = document.location.href; | |
if (window.location.href.indexOf('medium.com') > -1) { | |
window.location.replace(window.location.toString().replace(/medium.com/, 'scribe.rip')); | |
} | |
window.onload = function() { | |
var bodyList = document.querySelector("body") | |
var observer = new MutationObserver(function(mutations) { | |
mutations.forEach(function(mutation) { | |
if (oldHref != document.location.href) { | |
oldHref = document.location.href; | |
console.log('location changed!'); | |
if (window.location.href.indexOf('medium.com') > -1) { | |
window.location.replace(window.location.toString().replace(/medium.com/, 'scribe.rip')); | |
} | |
} | |
}); | |
}); | |
var config = { | |
childList: true, | |
subtree: true | |
}; | |
observer.observe(bodyList, config); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment