Skip to content

Commit

Permalink
migrated to manifest v3
Browse files Browse the repository at this point in the history
  • Loading branch information
fertkir committed Apr 21, 2023
1 parent ce96923 commit 3cce275
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/auth.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const authorize = function() {
if (IS_CHROMIUM && IS_DESKTOP) {
return function() {
return new Promise(function(resolve, reject) {
return new Promise(function(resolve) {
chrome.identity.getAuthToken({interactive: true}, resolve);
});
}
Expand Down Expand Up @@ -64,7 +64,7 @@ const authorize = function() {
});
}
}
return new Promise(function (resolve, reject) {
return new Promise(function (resolve) {
return invokeWhenReady(250, () => ACCESS_TOKEN, () => resolve(ACCESS_TOKEN));
});
}
Expand Down
3 changes: 3 additions & 0 deletions src/manifest-chrome-dev.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"background": {
"service_worker": "service-worker.js"
},
"key": "iihhhbkpnemncnmefhffhfiecmilppnf",
"oauth2": {
"client_id": "28806920398-1469m84teijjb48roc8vbrg4m4eoe23b.apps.googleusercontent.com"
Expand Down
3 changes: 3 additions & 0 deletions src/manifest-chrome.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"background": {
"service_worker": "service-worker.js"
},
"oauth2": {
"client_id": "444973037518-n5dc9rpf1hs992un81kjh3m1jdo7vomc.apps.googleusercontent.com",
"scopes": [
Expand Down
3 changes: 3 additions & 0 deletions src/manifest-firefox.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"background": {
"page": "background.html"
},
"browser_specific_settings": {
"gecko": {
"id": "{7cadcc4b-af6c-4227-a247-7122bfeea911}"
Expand Down
11 changes: 5 additions & 6 deletions src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"default_locale": "en",
"background": {
"page": "background.html"
},
"browser_action": {
"action": {
"default_icon": "icons/icon128.png"
},
"content_scripts": [{
Expand All @@ -23,7 +20,9 @@
"permissions": [
"identity",
"storage",
"webRequest",
"webRequest"
],
"host_permissions": [
"http://localhost/vocabulary-add/*",
"https://www.googleapis.com/*"
]
Expand Down
2 changes: 1 addition & 1 deletion src/polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (IS_CHROMIUM) {
runtime: {
onMessage: {
addListener: function(callback) {
chrome.extension.onMessage.addListener(callback);
chrome.runtime.onMessage.addListener(callback);
}
},
openOptionsPage: function() {
Expand Down
10 changes: 10 additions & 0 deletions src/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function tryImportScript(script) {
try {
importScripts(script);
} catch (e) {
console.log(e);
}
}
tryImportScript("polyfills.js");
tryImportScript("auth.js");
tryImportScript("background.js");

0 comments on commit 3cce275

Please sign in to comment.