Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Set up initial manifest v3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Jul 11, 2020
1 parent 161888d commit b86a757
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
31 changes: 31 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,37 @@
"node": true,
"webextensions": false
}
},
{
"files": [
"ext/bg/js/anki.js",
"ext/bg/js/anki-note-builder.js",
"ext/bg/js/backend.js",
"ext/bg/js/mecab.js",
"ext/bg/js/audio-uri-builder.js",
"ext/bg/js/clipboard-monitor.js",
"ext/bg/js/conditions.js",
"ext/bg/js/database.js",
"ext/bg/js/dictionary-importer.js",
"ext/bg/js/deinflector.js",
"ext/bg/js/dictionary.js",
"ext/bg/js/handlebars.js",
"ext/bg/js/json-schema.js",
"ext/bg/js/media-utility.js",
"ext/bg/js/options.js",
"ext/bg/js/profile-conditions.js",
"ext/bg/js/request.js",
"ext/bg/js/text-source-map.js",
"ext/bg/js/translator.js",
"ext/bg/js/util.js",
"ext/bg/js/background-main.js"
],
"env": {
"browser": false,
"serviceworker": true,
"es2017": true,
"webextensions": true
}
}
]
}
5 changes: 5 additions & 0 deletions ext/fg/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class Popup {
this._container = this._frame;
this._shadow = null;

// chrome.tabs.injectCSS fails on manifest v3 with error:
// Cannot access contents of the page. Extension manifest must request permission to access the respective host.
// Manually override position to workaround the stylesheet not being available.
this._frame.style.setProperty('position', 'fixed', 'important');

this._fullscreenEventListeners = new EventListenerCollection();
}

Expand Down
6 changes: 2 additions & 4 deletions ext/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Yomichan",
"version": "20.6.27.0",

Expand Down Expand Up @@ -29,8 +29,7 @@

"author": "Alex Yatskov",
"background": {
"page": "bg/background.html",
"persistent": true
"service_worker": "sw.js"
},
"content_scripts": [{
"matches": ["http://*/*", "https://*/*", "file://*/*"],
Expand Down Expand Up @@ -87,7 +86,6 @@
}
},
"web_accessible_resources": ["fg/float.html"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"applications": {
"gecko": {
"id": "[email protected]",
Expand Down
50 changes: 50 additions & 0 deletions ext/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 Yomichan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

self.importScripts(
'/mixed/lib/handlebars.min.js',
'/mixed/lib/jszip.min.js',
'/mixed/lib/wanakana.min.js',
'/mixed/js/core.js',
'/mixed/js/yomichan.js',
'/mixed/js/environment.js',
'/mixed/js/japanese.js',
'/mixed/js/audio-system.js',
'/mixed/js/object-property-accessor.js',
'/bg/js/anki.js',
'/bg/js/anki-note-builder.js',
'/bg/js/backend.js',
'/bg/js/mecab.js',
'/bg/js/audio-uri-builder.js',
'/bg/js/clipboard-monitor.js',
'/bg/js/conditions.js',
'/bg/js/database.js',
'/bg/js/dictionary-database.js',
'/bg/js/dictionary-importer.js',
'/bg/js/deinflector.js',
'/bg/js/dictionary.js',
'/bg/js/json-schema.js',
'/bg/js/media-utility.js',
'/bg/js/options.js',
'/bg/js/profile-conditions.js',
'/bg/js/request.js',
'/bg/js/template-renderer.js',
'/bg/js/text-source-map.js',
'/bg/js/translator.js',
'/bg/js/util.js',
'/bg/js/background-main.js'
);

0 comments on commit b86a757

Please sign in to comment.