Skip to content

Commit

Permalink
Merge all changes for MV3 and make it buildable for both MV2 and MV3
Browse files Browse the repository at this point in the history
  • Loading branch information
brookhong committed Nov 9, 2024
1 parent f152a9a commit 728e011
Show file tree
Hide file tree
Showing 32 changed files with 1,530 additions and 1,136 deletions.
40 changes: 37 additions & 3 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,52 @@ function modifyManifest(browser, mode, buffer) {
manifest.options_ui = {
page: "pages/options.html"
};
manifest.permissions.push("cookies",
"contextualIdentities");
manifest.permissions.push("cookies");
manifest.permissions.push("contextualIdentities");
manifest.permissions.push("<all_urls>");
} else if (browser === "safari") {
manifest.incognito = "split";
manifest.options_page = "pages/options.html";
manifest.permissions.push("<all_urls>");
manifest.background.persistent = false;
} else {
// chromium family
manifest.manifest_version = 3;
manifest.permissions.push("proxy");
manifest.permissions.push("tts");
manifest.permissions.push("downloads.shelf");
manifest.background.persistent = false;
manifest.permissions.push("favicon");
manifest.permissions.push("userScripts");
manifest.permissions.push("scripting");
manifest.incognito = "split";
manifest.options_page = "pages/options.html";
manifest.background = {
"service_worker": "background.js"
};
manifest.host_permissions = [
"<all_urls>"
];
manifest.web_accessible_resources = [
{
"resources": [
"api.js",
"pages/neovim.html",
"pages/default.js",
"pages/emoji.tsv",
"pages/l10n.json",
"pages/frontend.html",
"pages/pdf_viewer.html",
"pages/shadow.css",
"pages/default.css"
],
"matches": [
"<all_urls>"
]
}
];
manifest.action = manifest.browser_action;
delete manifest.browser_action;
delete manifest.content_security_policy;

if (mode === "development") {
manifest.key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAneIRqYRqG/0RoYzpWoyeeO8KxxvWZvIabABbeQyHQ2PFOf81j/O5J28HGAEQJ56AptKMTcTeG2qZga9B2u9k98OmRcGp8BDco6fh1vD6/x0fWfehPeub5IcEcQmCd1lBuVa8AtUqV3C+He5rS4g8dB8g8GRlSPPSiDSVNMv+iwKAk7TbM3TKz6DyFO8eCtWXr6wJCcYeJA+Mub7o8DKIHKgv8XH8+GbJGjeeIUBU7mlGlyS7ivdsG1V6D2/Ldx0O1e6sRn7f9jiC4Xy1N+zgZ7BshYbnlbwedomg1d5kuo5m4rS+8BgTchPPkhkvEs62MI4e+fmQd0oGgs7PtMSrTwIDAQAb";
Expand All @@ -54,6 +87,7 @@ module.exports = (env, argv) => {
};
const moduleEntries = {
'pages/options': './src/content_scripts/options.js',
'api': './src/user_scripts/index.js'
};
const pagesCopyOptions = {
ignore: [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Surfingkeys",
"version": "1.16.1",
"version": "1.17.3",
"description": "Map your keys for web surfing, expand your browser with javascript and keyboard.",
"main": "background.js",
"directories": {
Expand Down
8 changes: 5 additions & 3 deletions src/background/chrome.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
LOG,
filterByTitleOrUrl,
} from '../content_scripts/common/utils.js';
} from '../common/utils.js';
import {
_save,
dictFromArray,
Expand All @@ -26,6 +26,8 @@ function loadRawSettings(keys, cb, defaultSet) {
cb(subset);
});
} else if (localSavedAt < syncSavedAt) {
// don't sync local path
delete syncSet.localPath;
extendObject(rawSet, syncSet);
cb(getSubSettings(rawSet, keys));
_save(chrome.storage.local, syncSet);
Expand Down Expand Up @@ -117,7 +119,7 @@ function getLatestHistoryItem(text, maxResults, cb) {
text: "",
maxResults: prefetch
}, function(items) {
const filtered = filterByTitleOrUrl(items, text);
const filtered = filterByTitleOrUrl(items, text, false);
results = [...results, ...filtered];
if (items.length < maxResults || results.length >= maxResults) {
// all items are scanned or we have got what we want
Expand All @@ -134,7 +136,7 @@ function getLatestHistoryItem(text, maxResults, cb) {

function generatePassword() {
const random = new Uint32Array(8);
window.crypto.getRandomValues(random);
self.crypto.getRandomValues(random);
return Array.from(random).join("");
}

Expand Down
Loading

0 comments on commit 728e011

Please sign in to comment.