优化 排除非链接的 <a> 标签(这类 <a> 标签一般是用来执行 JS 代码的)

This commit is contained in:
xiu2
2021-08-29 21:21:00 +08:00
parent c09402dd94
commit 4b2a8bdf12
+4 -2
View File
@@ -1,6 +1,6 @@
// ==UserScript==
// @name 新标签页打开链接
// @version 1.0.1
// @version 1.0.2
// @author X.I.U
// @description 将网页中所有链接改为新标签页打开~
// @match *://*/*
@@ -28,7 +28,9 @@
// 修改为新标签页打开
function targetBlank() {
Array.from(document.links).forEach(function (_this) {
_this.target = '_blank'
if (_this.href && _this.href.slice(0,4) === 'http') {
_this.target = '_blank'
}
})
}
})();