Skip to content

Commit

Permalink
Merge pull request #131 from leonhartX/apps-scritp-api
Browse files Browse the repository at this point in the history
fix init config
  • Loading branch information
leonhartX authored Jan 3, 2021
2 parents 9ee9863 + bb44d57 commit 3ae95bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 32 deletions.
15 changes: 0 additions & 15 deletions background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 4 additions & 13 deletions src/gas-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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];
})
Expand Down
10 changes: 9 additions & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3ae95bf

Please sign in to comment.