Skip to content

Instantly share code, notes, and snippets.

@aveao
Last active February 27, 2017 11:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aveao/4835d796407e85dd17b78713f7ffe1bd to your computer and use it in GitHub Desktop.
Save aveao/4835d796407e85dd17b78713f7ffe1bd to your computer and use it in GitHub Desktop.
owsproxy.user.js
// ==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});
@aveao
Copy link
Author

aveao commented Jun 8, 2016

Not really my code anyways. Thanks Hakase for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment