18
18
< meta name ="keywords " content ="Simple Robot, simbot, Simple Robot 4, simbot4, Java, Java11, Kotlin, Kotlin Multiplatform, KMP, Kotlin JVM, Simple Robot v4, bot, forte, ForteScarlet, 法欧特斯卡雷特, 法欧特 ">
19
19
20
20
< script >
21
+ function _addIns ( then ) {
22
+ const elements = document . getElementsByTagName ( 'article' ) ;
23
+ if ( elements && elements . length > 0 ) {
24
+ const article = elements [ 0 ] ;
25
+ const insDiv = document . createElement ( 'div' ) ;
26
+ insDiv . setAttribute ( 'class' , 'ins_div' ) ;
27
+ const ins = document . createElement ( 'ins' ) ;
28
+ ins . setAttribute ( 'class' , 'adsbygoogle adsbygoogle_inline_ins' ) ;
29
+ /*ins.setAttribute('style', 'display:block');*/
30
+ ins . style . display = 'block' ;
31
+ ins . setAttribute ( 'data-ad-client' , 'ca-pub-4062299174917944' ) ;
32
+ ins . setAttribute ( 'data-ad-slot' , 'auto' ) ;
33
+ ins . setAttribute ( 'data-full-width-responsive' , 'true' ) ;
34
+ insDiv . appendChild ( ins ) ;
35
+ article . appendChild ( insDiv ) ;
36
+ then ( ) ;
37
+ }
38
+ }
39
+ function _pushAd ( log ) {
40
+ ( adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
41
+ console . log ( 'adsbygoogle pushed: ' , log || '(NULL)' ) ;
42
+ }
43
+
21
44
/*横向广告*/
45
+ if ( / M o b i | A n d r o i d | i P h o n e / i. test ( navigator . userAgent ) ) {
46
+ // 当前设备是移动设备
47
+ // https://www.ruanyifeng.com/blog/2021/09/detecting-mobile-browser.html
48
+ window . onload = ( event ) => {
49
+ _addIns ( ( ) => {
50
+ _pushAd ( 'after ins append.' ) ;
51
+ } ) ;
52
+ } ;
53
+ } else {
22
54
document . addEventListener ( "DOMContentLoaded" , ( event ) => {
23
55
try {
24
- const elements = document . getElementsByTagName ( 'article' ) ;
25
- if ( elements && elements . length > 0 ) {
26
- const article = elements [ 0 ] ;
27
- const insDiv = document . createElement ( 'div' ) ;
28
- insDiv . setAttribute ( 'class' , 'ins_div' ) ;
29
- const ins = document . createElement ( 'ins' ) ;
30
- ins . setAttribute ( 'class' , 'adsbygoogle adsbygoogle_inline_ins' ) ;
31
- /*ins.setAttribute('style', 'display:block');*/
32
- ins . style . display = 'block' ;
33
- ins . setAttribute ( 'data-ad-client' , 'ca-pub-4062299174917944' ) ;
34
- ins . setAttribute ( 'data-ad-slot' , 'auto' ) ;
35
- ins . setAttribute ( 'data-full-width-responsive' , 'true' ) ;
36
- insDiv . appendChild ( ins ) ;
37
- article . appendChild ( insDiv ) ;
38
- // in loaded
39
- try {
40
- window . addEventListener ( 'load' , ( event ) => {
41
- ( adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
42
- console . log ( 'adsbygoogle pushed after loaded.' ) ;
56
+ _addIns ( ( ) => {
57
+ window . addEventListener ( 'load' , ( event ) => {
58
+ _pushAd ( 'on event `load`' ) ;
43
59
} ) ;
44
- } catch ( e ) {
45
- ( adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
46
- console . log ( 'adsbygoogle pushed in DOMContentLoaded.' ) ;
47
- }
48
- }
60
+ } ) ;
49
61
} catch ( e ) { console . log ( e ) ; }
50
62
} ) ;
51
- //window.onload=function () {
52
- //try {
53
- //const elements = document.getElementsByTagName('article');
54
- //if (elements && elements.length > 0) {
55
- // const article = elements[0];
56
- // const insDiv = document.createElement('div');
57
- // insDiv.setAttribute('class', 'ins_div');
58
- // const ins = document.createElement('ins');
59
- // ins.setAttribute('class', 'adsbygoogle adsbygoogle_inline_ins');
60
- // /*ins.setAttribute('style', 'display:block');*/
61
- // ins.style.display = 'block';
62
- // ins.setAttribute('data-ad-client', 'ca-pub-4062299174917944');
63
- // ins.setAttribute('data-ad-slot', 'auto');
64
- // ins.setAttribute('data-full-width-responsive', 'true');
65
- // insDiv.appendChild(ins);
66
- // article.appendChild(insDiv);
67
- // (adsbygoogle = window.adsbygoogle || []).push({});
68
- // console.log('adsbygoogle pushed.');
69
- //}
70
- //} catch(e) {console.log(e);}
71
- //};
63
+ }
72
64
</ script >
0 commit comments