// ==UserScript==
// @
name V2EX-AllIMG
// @
version 1.0
// @
author lslqtz
// @
description Same as the name
// @
match *://
v2ex.com/*// @
match *://
www.v2ex.com/*// @
grant none
// @
inject-into page
// @
run-at document-end
// ==/UserScript==
window.OnImageError = function () {
let img = event.srcElement;
img.onerror = null;
img.outerHTML = img.src;
}
const imgExts = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.ico'];
let replyContentList = document.querySelectorAll('.reply_content a');
for (let replyContent of replyContentList) {
let imgURL = replyContent.href;
for (let imgExt of imgExts) {
if (imgURL.toLowerCase().endsWith(imgExt)) {
replyContent.innerHTML = '<img src="' + imgURL + '" class="embedded_image" rel="noreferrer" onerror="OnImageError()" />';
break;
}
}
}