Skip to content

Commit 3f0e6ce

Browse files
committed
6.2.0 update
최적화, 코드 정리
1 parent da3349b commit 3f0e6ce

File tree

5 files changed

+28
-131
lines changed

5 files changed

+28
-131
lines changed

background.js

+25-51
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,11 @@ const getCssByFont = (fontName) => {
88
}`
99
}
1010

11-
chrome.tabs.onUpdated.addListener(function (t) {
12-
checkEntryWS();
13-
});
1411

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+
4616
chrome.storage.local.get(['enabled', 'selectedTheme', 'fileData', 'fontName'], function(result) {
4717
if(result.enabled == undefined) { //최초 실행 시
4818
chrome.storage.local.set({'enabled': true});
@@ -58,11 +28,8 @@ function codes() {
5828
inject("default_theme/fonts.css", "file");
5929
inject(getCssByFont(result.fontName), "code");
6030
}
61-
62-
//if(url.startsWith("https://playentry.org/ws")) {
6331

64-
//chrome.tabs.executeScript({file: "water.js"});
65-
//chrome.scripting.executeScript({file: "water.js"});
32+
// 주입
6633
if(result.selectedTheme > -1) {
6734
if(result.selectedTheme == 0) {
6835
inject("default_theme/def_sans.css", "file");
@@ -72,22 +39,29 @@ function codes() {
7239
inject("default_theme/def_sepia.css", "file");
7340
} else {
7441
let code = result.fileData;
75-
inject(code, "code");
42+
inject(code, "code");
7643
}
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")
8644
}
87-
}
88-
//}
45+
}
8946
});
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+
9165
}
9266

9367
// 워터마크 삽입

manifest.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"manifest_version": 3,
3-
"name": "Pyer",
4-
"version": "6.1",
5-
"description": "엔트리 만들기 페이지에 CSS 테마를 적용시킵니다.",
3+
"name": "PYER: 엔트리 테마",
4+
"version": "6.2.0",
5+
"description": "엔트리 만들기 페이지에 다양한 테마와 글꼴을 적용시켜주는 크롬 확장 프로그램입니다.",
66
"permissions": [
77
"storage",
88
"unlimitedStorage",
@@ -30,5 +30,4 @@
3030
"content_security_policy": {
3131
"extension_pages": "script-src 'self'; object-src 'self'"
3232
}
33-
3433
}

materialize.min.js

-6
This file was deleted.

popup_guide.html

-70
This file was deleted.

test.svg

Whitespace-only changes.

0 commit comments

Comments
 (0)