NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Wikifeet URIs correction for EU visitors // @namespace mailto:everett.ducklair@gmail.com // @version 0.4 // @description Replaces the Wikifeet images URIs with the correct ones if you visit it from the EU // @author ED // @match https://www.wikifeet.com/* // @match https://www.wikifeetx.com/* // @match https://men.wikifeet.com/* // @grant none // @license GPL-3.0-or-later // @updateURL https://openuserjs.org/meta/ed/Wikifeet_URIs_correction_for_EU_visitors.meta.js // @downloadURL https://openuserjs.org/install/ed/Wikifeet_URIs_correction_for_EU_visitors.user.js // @copyright 2022, ed (https://openuserjs.org/users/ed) // ==/UserScript== // Replaces the image URI let replaceUri = aElement => { aElement.href = aElement.firstChild.style.backgroundImage.match(/https.*?jpg/)[0].replace('thumbs','pics') }; // Replaces the image URI in a wall post let replaceUriInWall = wallPost => [...wallPost.getElementsByTagName('a')].forEach(aElement => aElement.href.includes("/articles/17") && replaceUri(aElement)); // The two main sections const pics = document.getElementById('thepics'); const wall = document.getElementById('thewall'); // Callback function for the observer. It replaces the link on dinamically added comments and images const callback = (mutationList, observer) => { mutationList.reduce((nodes, mutation) => [...nodes, ...mutation.addedNodes], []).forEach(node => { replaceUriInWall(node); }) }; // Observes the comment section const config = { attributes: true, childList: true, subtree: true }; const observer = new MutationObserver(callback); observer.observe(pics, config); observer.observe(wall, config); // Replaces the URIs as soon as the page is loaded (function() { [...pics.getElementsByClassName('pic')].forEach(pic => replaceUri(pic.firstChild)); [...wall.childNodes].filter(childNode => childNode.id && childNode.id.startsWith("w_post")).forEach(post => replaceUriInWall(post)); })()