MCPcopy Create free account
hub / github.com/XIU2/UserScript / linksToImgs

Function linksToImgs

V2ex-Enhanced.user.js:331–340  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

329
330 // 链接转图片
331 function linksToImgs() {
332 let links = document.links;
333 Array.from(links).forEach(function (_this) {
334 if (/^https.*\.(?:jpg|jpeg|jpe|bmp|png|gif)/i.test(_this.href) && !(/<img\s/i.test(_this.innerHTML))) {
335 _this.innerHTML = `<img src="${_this.href}" style="max-width: 100%!important;" />`;
336 } else if (/^https:\/\/imgur\.com\/[a-z]+$/i.test(_this.href)) { // 针对没有文件后缀的 imgur 图床链接
337 _this.innerHTML = `<img src="${_this.href}.png" style="max-width: 100%!important;" />`;
338 }
339 });
340 }
341
342
343 // 快速回复(双击左右两侧空白处)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected