Skip to content

Commit

Permalink
Manifest V3
Browse files Browse the repository at this point in the history
  • Loading branch information
wtetsu committed May 12, 2022
1 parent cf58b62 commit 54fd7b2
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 110 deletions.
2 changes: 1 addition & 1 deletion __test__/main/core/rule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import rule from "../../../src/main/core/rule";
import fs from "fs";

beforeAll(() => {
define("chrome.extension.getURL", (name) => name);
define("chrome.runtime.getURL", (name) => name);
define("fetch", async (file) => {
const data = fs.readFileSync(file);
return {
Expand Down
448 changes: 352 additions & 96 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mouse-dictionary",
"version": "1.5.14",
"version": "1.6.0",
"repository": "https://github.com/wtetsu/mouse-dictionary.git",
"author": "wtetsu",
"license": "MIT",
Expand Down
18 changes: 11 additions & 7 deletions platform/manifest-chrome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifest_version": 2,
"name": "Mouse Dictionary",
"manifest_version": 3,
"version": "",
"description": "__MSG_appDesc__",
"default_locale": "en",
Expand All @@ -9,17 +9,16 @@
"page": "options/options.html",
"open_in_tab": true
},
"permissions": ["storage", "unlimitedStorage", "activeTab"],
"permissions": ["storage", "unlimitedStorage", "activeTab", "scripting"],
"background": {
"scripts": ["background.js"],
"persistent": false
"service_worker": "background.js"
},
"browser_action": {
"action": {
"default_icon": "icons/icon19.png",
"default_title": "Mouse Dictionary"
},
"commands": {
"_execute_browser_action": {
"_execute_action": {
"description": "Activate the extension"
},
"scroll_down": {
Expand All @@ -34,5 +33,10 @@
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"web_accessible_resources": ["data/*.json"]
"web_accessible_resources": [
{
"resources": ["data/rule.json", "data/dict*.json"],
"matches": ["<all_urls>"]
}
]
}
7 changes: 4 additions & 3 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import ExpiringQueue from "./queue";
import uniqueId from "./unique";

chrome.browserAction.onClicked.addListener(() => {
chrome.tabs.executeScript({
file: "./main.js",
chrome.action.onClicked.addListener((tab) => {
chrome.scripting.executeScript({
target: { tabId: tab.id },
files: ["main.js"],
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

const loadJson = async (fname) => {
const url = chrome.extension.getURL(fname);
const url = chrome.runtime.getURL(fname);
return fetch(url).then((r) => r.json());
};

Expand Down
2 changes: 1 addition & 1 deletion src/options/logic/dict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const registerDefaultDict = async (fnProgress: ProgressCallback): Promise
};

const loadJsonFile = async (fname: string): Promise<Record<string, any>> => {
const url = chrome.extension.getURL(fname);
const url = chrome.runtime.getURL(fname);
const response = await fetch(url);
return response.json();
};
Expand Down

0 comments on commit 54fd7b2

Please sign in to comment.