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

Function targetBlank

TargetBlank.user.js:26–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24
25 // 修改为新标签页打开
26 function targetBlank() {
27 document.head.appendChild(document.createElement('base')).target = '_blank'; // 让所有链接默认以新标签页打开
28 Array.from(document.links).forEach(function (_this) { // 排除特殊链接
29 if (_this.onclick || _this.href.slice(0,4) != 'http' || _this.getAttribute('href').slice(0,1) === '#') {
30 _this.target = '_self'
31 }
32 })
33 document.querySelectorAll('form').forEach(function (_this) { // 排除 form 标签
34 if (!_this.target) {_this.target = '_self'}
35 });
36 }
37
38
39 // 针对 Discuz! 论坛的帖子

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected