@Mirq, post #4
(function() {
'use strict';
const proxyPrefix = "proxy.duckduckgo.com";
const proxyImages = () => {
// Find all images hosted on imgur.com
const images = document.querySelectorAll('img[src*="imgur.com"]');
images.forEach(img => {
// Check if it's already proxied to avoid infinite loops and if img src is a full URL
if (img.src.includes('imgur.com') && !img.src.startsWith(proxyPrefix)) {
console.log('Proxying imgur image:', img.src); // Debugging
img.src = proxyPrefix + encodeURIComponent(img.src);
// Remove srcset to force the browser to use the new 'src' value
if (img.srcset) {
img.removeAttribute('srcset');
}
}
});
};
// Run immediately
proxyImages();
// Periodically re-run to catch lazy-loaded images (every 1.5 seconds)
setInterval(proxyImages, 1500);
// Also use MutationObserver for robust detection of new elements
const observer = new MutationObserver((mutations) => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
if (node.tagName === 'IMG') proxyImages(); // Check newly added image itself
node.querySelectorAll?.('img[src*="imgur.com"]').forEach(proxyImages); // Check images within added nodes
}
});
});
});
observer.observe(document.body, { childList: true, subtree: true });
})();Open the Developer Tools (press F12) and check the Console tab. You should see "Proxying imgur image..." messages if the script is working.
If images still do not appear, it's likely that the website ppa.pl is enforcing a strict Content Security Policy (CSP) that explicitly blocks connections to https://proxy.duckduckgo.com. In that case, the only reliable solution is to use a VPN service to bypass the UK's ISP-level blocking of Imgur.
@Mirq, post #11
// ==UserScript==
// @name Imgur Proxy for PPA.pl
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Proxy imgur. com images through DuckDuckGo on ppa.pl
// @author mirq
// @match https://ppa.pl/*
// @match https://www.ppa.pl/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
const proxyPrefix = "https://proxy.duckduckgo.com/iu/?u=";
const proxyImages = () => {
// Find all images hosted on imgur.com
const images = document.querySelectorAll('img[src*="imgur.com"]');
images.forEach(img => {
// Check if it's already proxied to avoid infinite loops
if (img.src. includes('imgur.com') && !img.src.includes('proxy. duckduckgo. com')) {
console.log('Proxying imgur image:', img.src); // Debugging
const encodedUrl = encodeURIComponent(img.src);
img.src = proxyPrefix + encodedUrl;
// Remove srcset to force the browser to use the new 'src' value
if (img.srcset) {
img.removeAttribute('srcset');
}
}
});
};
// Wait for DOM to be ready
if (document. readyState === 'loading') {
document. addEventListener('DOMContentLoaded', proxyImages);
} else {
proxyImages();
}
// Periodically re-run to catch lazy-loaded images (every 1.5 seconds)
setInterval(proxyImages, 1500);
// Also use MutationObserver for robust detection of new elements
const observer = new MutationObserver((mutations) => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE) {
if (node.tagName === 'IMG' && node.src?. includes('imgur.com')) {
proxyImages(); // Check newly added image itself
}
if (node.querySelectorAll) {
const imgurImages = node.querySelectorAll('img[src*="imgur.com"]');
if (imgurImages.length > 0) {
proxyImages(); // Check images within added nodes
}
}
}
});
});
});
// Start observing once body is available
const startObserver = () => {
if (document. body) {
observer.observe(document.body, { childList: true, subtree: true });
} else {
setTimeout(startObserver, 100);
}
};
startObserver();
})();