From bb44d57de139d0113a3c125229e171146fd90ef8 Mon Sep 17 00:00:00 2001 From: leonhartX Date: Sun, 3 Jan 2021 17:11:39 +0900 Subject: [PATCH] fix init config --- background/background.js | 15 --------------- manifest.json | 5 ++--- src/gas-hub.js | 17 ++++------------- src/util.js | 10 +++++++++- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/background/background.js b/background/background.js index 2091cde..8d8cfd9 100644 --- a/background/background.js +++ b/background/background.js @@ -2,21 +2,6 @@ let googleApiKey; -chrome.runtime.onInstalled.addListener(() => { - chrome.declarativeContent.onPageChanged.removeRules(undefined, () => { - chrome.declarativeContent.onPageChanged.addRules([{ - conditions: [ - new chrome.declarativeContent.PageStateMatcher({ - pageUrl: { - urlContains: 'script.google.com' - } - }) - ], - actions: [new chrome.declarativeContent.ShowPageAction()] - }]); - }); -}); - chrome.runtime.onMessage.addListener((msg, sender, callback) => { if (!msg.cmd) return; switch (msg.cmd) { diff --git a/manifest.json b/manifest.json index b33ae4a..9c298c9 100644 --- a/manifest.json +++ b/manifest.json @@ -55,11 +55,10 @@ "permissions": [ "https://script.google.com/*", "https://www.googleapis.com/oauth2/v4/token", + "https://gitlab.com/*", "identity", "storage", - "declarativeContent", - "webRequest", - "https://gitlab.com/*" + "webRequest" ], "oauth2": { "client_id": "971735641612-plgfavrj0vhpsd1brvquo4qt7m91ujs6.apps.googleusercontent.com", diff --git a/src/gas-hub.js b/src/gas-hub.js index 8c8cb4f..4047c5c 100644 --- a/src/gas-hub.js +++ b/src/gas-hub.js @@ -250,18 +250,9 @@ function initPageEvent() { $(document).on('click', '#config-button', () => { let config = getConfig(); - if (!config) { - config = { - filetype: '.gs', - ignorePattern: [], - manifestEnabled: true, - } - } - if (config) { - $('#selected-suffix').text(config.filetype); - $('#manage-manifest').prop("checked", config.manifestEnabled); - $('#ignore-pattern').val(config.ignorePattern.join(';')); - } + $('#selected-suffix').text(config.filetype); + $('#manage-manifest').prop("checked", config.manifestEnabled); + $('#ignore-pattern').val(config.ignorePattern.join(';')); changeModalState('config', true); }); @@ -390,7 +381,7 @@ function showDiff(code, type) { let p = new RegExp(svconfig.ignorePattern[i]); if (svp.test(file)) return false; } - const regex = new RegExp(`(.*?)(${context.bindConfig[getId()].filetype}|\.html)$`) + const regex = new RegExp(`(.*?)(${getConfig().filetype}|\.html)$`) const match = file.match(regex); return match && match[1] && match[2]; }) diff --git a/src/util.js b/src/util.js index ef830d1..53e958b 100644 --- a/src/util.js +++ b/src/util.js @@ -14,7 +14,15 @@ function getBranch() { } function getConfig() { - return context.bindConfig[getId()]; + let config = context.bindConfig[getId()]; + if (!config) { + config = { + filetype: '.gs', + ignorePattern: [], + manifestEnabled: true, + } + } + return config; } function isGist() {