Skip to content

Commit 68fd7cb

Browse files
committed
优化 样式载入成功率
1 parent 59cf6c6 commit 68fd7cb

3 files changed

Lines changed: 36 additions & 14 deletions

File tree

3dm-Beautification.user.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 3DM论坛美化
3-
// @version 1.0.0
3+
// @version 1.0.1
44
// @author X.I.U
55
// @description 精简多余内容、样式优化
66
// @icon https://www.3dmgame.com/favicon.ico
@@ -9,9 +9,9 @@
99
// @run-at document-start
1010
// @namespace https://greasyfork.org/scripts/413593
1111
// ==/UserScript==
12-
12+
1313
(function() {
14-
var style_Add = document.createElement('style');
14+
let style_Add = document.createElement('style');
1515
style_Add.innerHTML = `
1616
[url=home.php?mod=space&uid=945662]@media[/url] (min-width:1366px) {
1717
body {
@@ -87,5 +87,14 @@ textarea#fastpostmessage {
8787
border-top: 0;
8888
border-bottom: 0;
8989
}`;
90-
document.head.appendChild(style_Add);
90+
if (document.head) {
91+
document.head.appendChild(style_Add);
92+
} else {
93+
let timer = setInterval(function(){
94+
if (document.head) {
95+
document.head.appendChild(style_Add);
96+
clearInterval(timer);
97+
}
98+
}, 1);
99+
}
91100
})();

52pojie-Beautification.user.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name 吾爱破解论坛美化
3-
// @version 1.0.7
3+
// @version 1.0.8
44
// @author X.I.U
55
// @description 精简多余内容、样式优化
66
// @match *://www.52pojie.cn/*
@@ -149,11 +149,15 @@ textarea#fastpostmessage {
149149
style = style_2
150150
if (menu_value('menu_rule')) style += style_1;
151151
style_Add.innerHTML = style;
152-
let timer = setInterval(function(){
153-
if (document.head) {
154-
document.head.appendChild(style_Add);
155-
clearInterval(timer);
156-
}
157-
}, 10);
152+
if (document.head) {
153+
document.head.appendChild(style_Add);
154+
} else {
155+
let timer = setInterval(function(){
156+
if (document.head) {
157+
document.head.appendChild(style_Add);
158+
clearInterval(timer);
159+
}
160+
}, 1);
161+
}
158162
}
159163
})();

Zhiyoo-Beautification.user.js

Lines changed: 12 additions & 3 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
// @icon http://bbs.zhiyoo.net/favicon.ico
@@ -11,7 +11,7 @@
1111
// ==/UserScript==
1212

1313
(function() {
14-
var style_Add = document.createElement('style');
14+
let style_Add = document.createElement('style');
1515
style_Add.innerHTML = `
1616
/* 精简多于内容 */
1717
.forum_top,#main_sidebar,.drag,.nav,.tps,.bm.bml,.ct2 .sd,.mn div.box.cl:nth-of-type(3),#f_pst,.plc.plm,#diy_like1,#hm_qrcode_main,#ft,.po.bbd.reply_p,.ft_top.cl,div a[href="https://weibo.com/372458419"] {
@@ -43,5 +43,14 @@
4343
#postlist .pcb img {
4444
max-width: 30%;
4545
}`;
46-
document.head.appendChild(style_Add);
46+
if (document.head) {
47+
document.head.appendChild(style_Add);
48+
} else {
49+
let timer = setInterval(function(){
50+
if (document.head) {
51+
document.head.appendChild(style_Add);
52+
clearInterval(timer);
53+
}
54+
}, 1);
55+
}
4756
})();

0 commit comments

Comments
 (0)