Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mannually install option. #95

Merged
merged 1 commit into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This extension brings the following functionality to ungoogled-chromium (and oth
- Automatically checks for updates to your installed extensions and displays them on the badge.
![Example Image](https://raw.githubusercontent.com/NeverDecaf/chromium-web-store/master/sample2.PNG)
# Read this first
- You **must** change the flag `chrome://flags/#extension-mime-request-handling` to `Always prompt for install` if you are using `ungoogled-chromium`. The majority of issues reported by users are solved by setting this flag. **If you do not set this flag, installing or updating an extension will instead download a CRX file or fail entirely.**
- **To avoid the restriction like `CRX_REQUIRED_PROOF_MISSING` of the downloaded .CRX, you must:**
- for `ungoogled-chromium`: change the flag `chrome://flags/#extension-mime-request-handling` to `Always prompt for install` if you are using `ungoogled-chromium`.
- for others: extension options > Advanced > enable `Manually Install`
- Some extensions may not update until you restart your browser, see [#4](https://github.com/NeverDecaf/chromium-web-store/issues/4).
#### Usage
- Pin the Chromium Web Store badge in your browser's toolbar. (Badges are hidden by default)
Expand Down
20 changes: 20 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
}
}
},
"options_advanced": {
"message": "Advanced",
"description": ""
},
"options_manuallyInstallTooltip":{
"message": "Avoid the 'CRX_REQUIRED_PROOF_MISSING' restriction of Chrome to third-party extensions source",
"description": ""
},
"options_manuallyInstall":{
"message": "ManuallyInstall",
"description": ""
},
"options_importExportInstallAllButton": {
"message": "Install All",
"description": ""
Expand Down Expand Up @@ -106,5 +118,13 @@
"webstore_removeButton": {
"message": "Remove from Chromium",
"description": ""
},
"notify_manuallyInstall_title":{
"message": "Extension downloaded! Please manually install:",
"description": ""
},
"notify_manuallyInstall_message":{
"message": "1. enable developer mode\n2. drag .crx into page",
"description": ""
}
}
20 changes: 20 additions & 0 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@
}
}
},
"options_advanced": {
"message": "高级",
"description": ""
},
"options_manuallyInstallTooltip":{
"message": "解除 Chrome 等浏览器对第三方插件源的 'CRX_REQUIRED_PROOF_MISSING' 屏蔽",
"description": ""
},
"options_manuallyInstall":{
"message": "手动安装",
"description": ""
},
"options_importExportInstallAllButton": {
"message": "安装全部",
"description": ""
Expand Down Expand Up @@ -106,5 +118,13 @@
"webstore_removeButton": {
"message": "从 Chromium 中删除",
"description": ""
},
"notify_manuallyInstall_title":{
"message": "插件下载完成!请手动安装:",
"description": ""
},
"notify_manuallyInstall_message":{
"message": "1. 激活“开发者模式”\n2. 拖拽文件",
"description": ""
}
}
7 changes: 6 additions & 1 deletion src/managed_storage.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
"title": "Update check interval in minutes.",
"description": "Default is 60",
"type": "integer"
},
"manually_install": {
"title": "Manually install extensions.",
"description": "Default value is false",
"type": "boolean"
}
}
}
}
3 changes: 2 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"storage",
"alarms",
"contextMenus",
"downloads"
"downloads",
"notifications"
],
"optional_permissions": ["https://*/", "http://*/"],
"browser_action": {
Expand Down
5 changes: 5 additions & 0 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ <h2 data-localize="__MSG_options_updateHeading__">Update Options</h2>
</div>
<h2 data-localize="__MSG_options_ignoredExtensionsHeading__">Ignored Extensions</h2>
<div id='updatetoggle'></div>
<h2 data-localize="__MSG_options_advanced__">Advanced</h2>
<label title="__MSG_options_manuallyInstallTooltip__">
<input type="checkbox" id="manually_install" /> <span data-localize="__MSG_options_manuallyInstall__">Manually
install</span>
</label>
<h2 data-localize="__MSG_options_importExportHeading__">Import / Export</h2>
<div>
<textarea id="import_export_list"></textarea>
Expand Down
35 changes: 27 additions & 8 deletions src/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var default_options = {
check_store_apps: true,
check_external_apps: true,
update_period_in_minutes: 60,
manually_install: false,
};
const tabsAwaitingInstall = new Set();

Expand Down Expand Up @@ -48,12 +49,12 @@ function startupTasks() {
delayInMinutes: Math.max(
1,
settings.update_period_in_minutes -
Math.floor(
(Date.now() -
localstore.last_scheduled_update) /
1000 /
60
)
Math.floor(
(Date.now() -
localstore.last_scheduled_update) /
1000 /
60
)
),
periodInMinutes: settings.update_period_in_minutes,
});
Expand Down Expand Up @@ -127,8 +128,26 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
extensionsDownloads[request.downloadId] = true;
}
if (request.newTabUrl) {
chrome.tabs.create({ active: false }, (tab) => {
chrome.tabs.update(tab.id, { url: request.newTabUrl });
chrome.storage.sync.get(default_options, function (settings) {
if (settings.manually_install) {
chrome.downloads.download({
url: request.newTabUrl,
saveAs: true
}, () => {
chrome.tabs.create({
url: 'about:extensions'
});
chrome.notifications.create('manually_install', {
type: 'basic',
iconUrl: "assets/icon/icon_128.png",
title: chrome.i18n.getMessage('notify_manuallyInstall_title'),
message: chrome.i18n.getMessage("notify_manuallyInstall_message")
});
})
} else
chrome.tabs.create({ active: false }, (tab) => {
chrome.tabs.update(tab.id, { url: request.newTabUrl });
});
});
}
if (request.checkExtInstalledId) {
Expand Down
1 change: 1 addition & 0 deletions src/scripts/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function load_options() {
check_store_apps: true,
check_external_apps: true,
update_period_in_minutes: 60,
manually_install: false,
};
chrome.management.getAll(function (e) {
e = e.filter((ex) => ex.updateUrl);
Expand Down
1 change: 1 addition & 0 deletions src/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function checkForUpdates(
check_store_apps: true,
check_external_apps: true,
removed_extensions: {},
manually_install: false,
};
e.forEach(function (ex) {
default_options[ex.id] = false;
Expand Down