Last active
February 27, 2017 11:51
-
-
Save aveao/4835d796407e85dd17b78713f7ffe1bd to your computer and use it in GitHub Desktop.
owsproxy.user.js
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 owsproxy | |
// @namespace ardao.me | |
// @version 0.1 | |
// @description For those who can't see my homebrew imgur posts, proxies them through ardao.me | |
// @author ardaozkal | |
// @match *://chat.stackexchange.com/* | |
// @match *://chat.stackoverflow.com/* | |
// @match *://chat.meta.stackexchange.com/* | |
// @grant none | |
// ==/UserScript== | |
function unthumbnailChildLinks (node) { | |
if (node.nodeType !== Node.ELEMENT_NODE) | |
return; | |
var links = node.getElementsByTagName('a'); | |
[].forEach.call(links, function (a) { | |
a.href = a.href.replace('https://0ws.pw/', 'http://ardao.me/ows/'); | |
a.href = a.href.replace('http://0ws.pw/', 'http://ardao.me/ows/'); | |
}); | |
var srcs = node.getElementsByTagName('img'); | |
[].forEach.call(srcs, function (b) { | |
b.src = b.src.replace('https://0ws.pw/', 'http://ardao.me/ows/'); | |
b.src = b.src.replace('http://0ws.pw/', 'http://ardao.me/ows/'); | |
}); | |
} | |
unthumbnailChildLinks(document.body); | |
var mo = new MutationObserver(function (items) { | |
items.forEach(function (item) { | |
if (!item.addedNodes) | |
return; | |
[].forEach.call(item.addedNodes, unthumbnailChildLinks); | |
}); | |
}); | |
mo.observe(document.getElementById('main'), { childList : true, subtree : true}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not really my code anyways. Thanks Hakase for your help