Skip to content

Commit d2b8ffa

Browse files
committed
新增 [链接转图片] 支持无文件后缀的 imgur 图床链接
1 parent e617277 commit d2b8ffa

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

V2ex-Enhanced.user.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name V2EX 增强
3-
// @version 1.1.8
3+
// @version 1.2.0
44
// @author X.I.U
55
// @description 自动签到、链接转图片、自动无缝翻页、使用 SOV2EX 搜索、回到顶部(右键点击两侧空白处)、快速回复(左键双击两侧空白处)、新标签页打开链接、标签页伪装为 Github(摸鱼)
66
// @match *://v2ex.com/*
@@ -277,7 +277,7 @@
277277
}
278278

279279

280-
// 替换为 sov2ex 搜索,代码来自 v2ex-plus 扩展:https://github.com/sciooga/v2ex-plus (懒得重复造轮子了~
280+
// 替换为 sov2ex 搜索,代码来自 v2ex-plus 扩展:https://github.com/sciooga/v2ex-plus (懒得重复造轮子了~
281281
function soV2ex() {
282282
document.body.appendChild(document.createElement('script')).textContent = `
283283
var $search = $('#search')
@@ -327,12 +327,14 @@
327327
}
328328

329329

330-
// 链接转图片,修改自:https://greasyfork.org/scripts/14182
330+
// 链接转图片
331331
function linksToImgs() {
332332
let links = document.links;
333333
Array.from(links).forEach(function (_this) {
334334
if (/^https.*\.(?:jpg|jpeg|jpe|bmp|png|gif)/i.test(_this.href) && !(/<img\s/i.test(_this.innerHTML))) {
335335
_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;" />`;
336338
}
337339
});
338340
}

0 commit comments

Comments
 (0)