Skip to content

Commit bb44d57

Browse files
committed
fix init config
1 parent 083dcd7 commit bb44d57

File tree

4 files changed

+15
-32
lines changed

4 files changed

+15
-32
lines changed

background/background.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22

33
let googleApiKey;
44

5-
chrome.runtime.onInstalled.addListener(() => {
6-
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
7-
chrome.declarativeContent.onPageChanged.addRules([{
8-
conditions: [
9-
new chrome.declarativeContent.PageStateMatcher({
10-
pageUrl: {
11-
urlContains: 'script.google.com'
12-
}
13-
})
14-
],
15-
actions: [new chrome.declarativeContent.ShowPageAction()]
16-
}]);
17-
});
18-
});
19-
205
chrome.runtime.onMessage.addListener((msg, sender, callback) => {
216
if (!msg.cmd) return;
227
switch (msg.cmd) {

manifest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@
5555
"permissions": [
5656
"https://script.google.com/*",
5757
"https://www.googleapis.com/oauth2/v4/token",
58+
"https://gitlab.com/*",
5859
"identity",
5960
"storage",
60-
"declarativeContent",
61-
"webRequest",
62-
"https://gitlab.com/*"
61+
"webRequest"
6362
],
6463
"oauth2": {
6564
"client_id": "971735641612-plgfavrj0vhpsd1brvquo4qt7m91ujs6.apps.googleusercontent.com",

src/gas-hub.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -250,18 +250,9 @@ function initPageEvent() {
250250

251251
$(document).on('click', '#config-button', () => {
252252
let config = getConfig();
253-
if (!config) {
254-
config = {
255-
filetype: '.gs',
256-
ignorePattern: [],
257-
manifestEnabled: true,
258-
}
259-
}
260-
if (config) {
261-
$('#selected-suffix').text(config.filetype);
262-
$('#manage-manifest').prop("checked", config.manifestEnabled);
263-
$('#ignore-pattern').val(config.ignorePattern.join(';'));
264-
}
253+
$('#selected-suffix').text(config.filetype);
254+
$('#manage-manifest').prop("checked", config.manifestEnabled);
255+
$('#ignore-pattern').val(config.ignorePattern.join(';'));
265256
changeModalState('config', true);
266257
});
267258

@@ -390,7 +381,7 @@ function showDiff(code, type) {
390381
let p = new RegExp(svconfig.ignorePattern[i]);
391382
if (svp.test(file)) return false;
392383
}
393-
const regex = new RegExp(`(.*?)(${context.bindConfig[getId()].filetype}|\.html)$`)
384+
const regex = new RegExp(`(.*?)(${getConfig().filetype}|\.html)$`)
394385
const match = file.match(regex);
395386
return match && match[1] && match[2];
396387
})

src/util.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ function getBranch() {
1414
}
1515

1616
function getConfig() {
17-
return context.bindConfig[getId()];
17+
let config = context.bindConfig[getId()];
18+
if (!config) {
19+
config = {
20+
filetype: '.gs',
21+
ignorePattern: [],
22+
manifestEnabled: true,
23+
}
24+
}
25+
return config;
1826
}
1927

2028
function isGist() {

0 commit comments

Comments
 (0)