Skip to content

Commit 4b2a8bd

Browse files
committed
优化 排除非链接的 <a> 标签(这类 <a> 标签一般是用来执行 JS 代码的)
1 parent c09402d commit 4b2a8bd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

TargetBlank.user.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 新标签页打开链接
3-
// @version 1.0.1
3+
// @version 1.0.2
44
// @author X.I.U
55
// @description 将网页中所有链接改为新标签页打开~
66
// @match *://*/*
@@ -28,7 +28,9 @@
2828
// 修改为新标签页打开
2929
function targetBlank() {
3030
Array.from(document.links).forEach(function (_this) {
31-
_this.target = '_blank'
31+
if (_this.href && _this.href.slice(0,4) === 'http') {
32+
_this.target = '_blank'
33+
}
3234
})
3335
}
3436
})();

0 commit comments

Comments
 (0)