NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Bitcointalk images
// @namespace ecuamobi
// @author EcuaMobi
// @description Makes images load faster by using rsz.io as proxy and reduces big images to improve readability
// @include https://bitcointalk.org/index.php?topic=*
// @include https://bitcointalk.org/index.php?action=profile;u=*;sa=showPosts
// @include https://bitcointalk.org/index.php?action=profile;threads;u=*;sa=showPosts
// @require https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.min.js
// @version 0.1
// @license MIT
// @grant none
// ==/UserScript==
(() => {
// Max allowed size
const MAX_WIDTH = 600;
const MAX_HEIGHT = 400;
$('img[src*="https://ip.bitcointalk.org/?u="]')
.each((i, e) => {
// rsz.io proxy
const image = 'https://rsz.io/' + new URL(e.src).searchParams.get("u").replace("http://", "").replace("https://", "").replace("ftp://", "");
// Preload full image
const preload = $('<span style="position: absolute; visibility: hidden;"><img /></span>').insertBefore(e);
preload.children().on('load', function() {preload.children().toggle(false)} ).attr("src", image);
// Replace SRC
const imageMini = image + '?w=' + MAX_WIDTH + '&h=' + MAX_HEIGHT + '&mode=max&scale=down';
e.src = imageMini;
// Remove with & height
e.removeAttribute('width');
e.removeAttribute('heigth');
// Show the full image on hover
$(e).mouseenter(function() {
e.src = image;
}).mouseleave(function() {
e.src = imageMini;
});
});
})();