1+ < script >
2+ function getCookie ( name ) {
3+ const decodedCookie = decodeURIComponent ( document . cookie ) ;
4+ const cookies = decodedCookie . split ( ';' ) ;
5+ const fullCookieName = name + "=" ;
6+ for ( let i = 0 ; i < cookies . length ; i ++ ) {
7+ const cookie = cookies [ i ] . trim ( ) ;
8+ if ( cookie . indexOf ( fullCookieName ) === 0 ) {
9+ return cookie . substring ( fullCookieName . length , cookie . length ) ;
10+ }
11+ }
12+ return undefined ;
13+ }
14+ document . addEventListener ( 'DOMContentLoaded' , ( event ) => {
15+ if ( document . mB && typeof document . mB . show === 'function' ) {
16+ if ( getCookie ( 'mbShow' ) !== 'true' ) {
17+ document . mB . show ( "Service Worker 进行了重写!网页出现错误时,可以试试页面底部的两点按键!" , true , "我已知晓" , "#FFF" , "top-right" , 5000 ) ;
18+ document . cookie = "mbShow=true; path=/" ;
19+ }
20+ } else {
21+ console . error ( 'mB is not defined or show is not a function!' ) ;
22+ }
23+ pagemap ( document . querySelector ( '#pagemap' ) , {
24+ viewport : null ,
25+ styles : {
26+ 'header,footer,section,article' : 'rgba(0,0,0,0.08)' ,
27+ 'h1,a' : 'rgba(0,0,0,0.10)' ,
28+ 'h2,h3,h4' : 'rgba(0,0,0,0.08)'
29+ } ,
30+ back : 'rgba(0,0,0,0.02)' ,
31+ view : 'rgba(0,0,0,0.05)' ,
32+ drag : 'rgba(0,0,0,0.10)' ,
33+ interval : null
34+ } ) ;
35+ } ) ;
36+ </ script >
0 commit comments