@@ -8,41 +8,11 @@ const getCssByFont = (fontName) => {
8
8
}`
9
9
}
10
10
11
- chrome . tabs . onUpdated . addListener ( function ( t ) {
12
- checkEntryWS ( ) ;
13
- } ) ;
14
11
15
-
16
- chrome . tabs . onActivated . addListener ( function ( tt ) {
17
- checkEntryWS ( ) ;
18
- } ) ;
19
-
20
- // 엔트리 만들기 페이지인지 확인 후 코드 실행
21
- function checkEntryWS ( ) {
22
- chrome . tabs . query ( { active : true , lastFocusedWindow : true } , tabs => {
23
- if ( tabs [ 0 ] . url . startsWith ( 'https://playentry.org/ws' ) ) { codes ( ) ; }
24
- } ) ;
25
- }
26
-
27
- function inject ( path , type ) {
28
- var PYER_VERSION = chrome . runtime . getManifest ( ) . version ;
29
- chrome . tabs . query ( { active :true , currentWindow : true } , function ( tabs ) {
30
- if ( tabs [ 0 ] . id ) {
31
- if ( type == "file" ) {
32
- chrome . scripting . insertCSS ( { target : { tabId : tabs [ 0 ] . id } , files : [ path ] } ) ;
33
- } else {
34
- chrome . scripting . insertCSS ( { css : path , target : { tabId : tabs [ 0 ] . id } } ) ;
35
- }
36
-
37
- chrome . scripting . executeScript ( { target : { tabId : tabs [ 0 ] . id } , func : addWater , args : [ PYER_VERSION ] } ) ;
38
- }
39
- } )
40
-
41
- }
42
-
43
- function codes ( ) {
44
- // chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function (tabs) {
45
- // let url = tabs[0].url;
12
+ chrome . tabs . onUpdated . addListener ( ( tabId , changeInfo , tab ) => {
13
+ if ( tab . url . startsWith ( 'https://playentry.org/ws' ) ) {
14
+ if ( changeInfo . status === "loading" ) {
15
+
46
16
chrome . storage . local . get ( [ 'enabled' , 'selectedTheme' , 'fileData' , 'fontName' ] , function ( result ) {
47
17
if ( result . enabled == undefined ) { //최초 실행 시
48
18
chrome . storage . local . set ( { 'enabled' : true } ) ;
@@ -58,11 +28,8 @@ function codes() {
58
28
inject ( "default_theme/fonts.css" , "file" ) ;
59
29
inject ( getCssByFont ( result . fontName ) , "code" ) ;
60
30
}
61
-
62
- //if(url.startsWith("https://playentry.org/ws")) {
63
31
64
- //chrome.tabs.executeScript({file: "water.js"});
65
- //chrome.scripting.executeScript({file: "water.js"});
32
+ // 주입
66
33
if ( result . selectedTheme > - 1 ) {
67
34
if ( result . selectedTheme == 0 ) {
68
35
inject ( "default_theme/def_sans.css" , "file" ) ;
@@ -72,22 +39,29 @@ function codes() {
72
39
inject ( "default_theme/def_sepia.css" , "file" ) ;
73
40
} else {
74
41
let code = result . fileData ;
75
- inject ( code , "code" ) ;
42
+ inject ( code , "code" ) ;
76
43
}
77
- // inject(`button,li:not(.entryContainerListElementWorkspace),a {
78
-
79
- // transition: filter .2s;
80
- // }
81
-
82
- // button:hover,li:not(.entryContainerListElementWorkspace):hover,a:hover {
83
- // filter: brightness(80%);
84
- // }
85
- // `, "code")
86
44
}
87
- }
88
- //}
45
+ }
89
46
} ) ;
90
- //});
47
+ } else {
48
+ var PYER_VERSION = chrome . runtime . getManifest ( ) . version ;
49
+ chrome . scripting . executeScript ( { target : { tabId : tabId } , func : addWater , args : [ PYER_VERSION ] } ) ;
50
+ }
51
+ }
52
+ } )
53
+
54
+ function inject ( path , type ) {
55
+ chrome . tabs . query ( { active :true , currentWindow : true } , function ( tabs ) {
56
+ if ( tabs [ 0 ] . id ) {
57
+ if ( type == "file" ) {
58
+ chrome . scripting . insertCSS ( { target : { tabId : tabs [ 0 ] . id } , files : [ path ] } ) ;
59
+ } else {
60
+ chrome . scripting . insertCSS ( { css : path , target : { tabId : tabs [ 0 ] . id } } ) ;
61
+ }
62
+ }
63
+ } )
64
+
91
65
}
92
66
93
67
// 워터마크 삽입
0 commit comments