Skip to content

Commit

Permalink
pack 1.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverDecaf committed Oct 7, 2022
1 parent 8eba132 commit ceffb30
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 222 deletions.
Binary file modified Chromium Web Store.crx
Binary file not shown.
7 changes: 6 additions & 1 deletion en_nolocale/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, set to true if not using ungoogled chromium",
"type": "boolean"
}
}
}
}
2 changes: 1 addition & 1 deletion en_nolocale/manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"author": "NeverDecaf", "manifest_version": 2, "name": "Chromium Web Store", "description": "Enables installation and semi-automatic updating for extensions from the Chrome Web Store (or elsewhere) on Chromium based browsers.", "version": "1.4.4.2", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqF/d41Q7agjkUzYq8ZGbQr8XW8mmEIMXOnR1uCTnYLL+Dm9Z+LO50xZukOISNy6zFxpI8ts/OGLsm+I2x9+UprUU4/EVdmxuwegFE6NBoEhHoRNYY0gbXZkaU8YY/XwzjVY/k18DDhl5NYPEnF6uq4Oyidg+xtd3W4+iGYczuOLER1Tp5y614zOTphcvFYhvUkCijQ6HT1TtRq/34SlFoRQqo4SFiLriK451xWIcfwiMLIekWrdoQa1v8dqIlMA3r6CKc0QykJpSYbiyormWiZ0hl2HLpkZ85mD9V0eDQ5RCtb6vkybK7INcq4yKQV4YkXhr9NpX9U4re4dlFQjEJQIDAQAB", "permissions": ["management", "https://clients2.google.com/service/*", "storage", "alarms", "contextMenus", "downloads"], "optional_permissions": ["https://*/", "http://*/"], "browser_action": {"default_icon": {"16": "assets/icon/icon_16.png", "24": "assets/icon/icon_24.png"}, "default_title": "Chromium Web Store", "default_popup": "popup.html"}, "content_scripts": [{"matches": ["https://chrome.google.com/webstore*", "https://addons.opera.com/*extensions/details/*", "https://microsoftedge.microsoft.com/addons/*"], "js": ["scripts/inject.js"], "run_at": "document_end"}], "background": {"scripts": ["scripts/util.js", "scripts/background.js"], "persistent": false}, "update_url": "https://raw.githubusercontent.com/NeverDecaf/chromium-web-store/master/updates_en_nolocale.xml", "icons": {"16": "assets/icon/icon_16.png", "24": "assets/icon/icon_24.png", "32": "assets/icon/icon_32.png", "48": "assets/icon/icon_48.png", "64": "assets/icon/icon_64.png", "128": "assets/icon/icon_128.png"}, "homepage_url": "https://github.com/NeverDecaf/chromium-web-store", "options_ui": {"page": "options.html", "chrome_style": true}, "storage": {"managed_schema": "managed_storage.json"}}
{"author": "NeverDecaf", "manifest_version": 3, "name": "Chromium Web Store", "description": "Enables installation and semi-automatic updating for extensions from the Chrome Web Store (or elsewhere) on Chromium based browsers.", "version": "1.5.2", "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqF/d41Q7agjkUzYq8ZGbQr8XW8mmEIMXOnR1uCTnYLL+Dm9Z+LO50xZukOISNy6zFxpI8ts/OGLsm+I2x9+UprUU4/EVdmxuwegFE6NBoEhHoRNYY0gbXZkaU8YY/XwzjVY/k18DDhl5NYPEnF6uq4Oyidg+xtd3W4+iGYczuOLER1Tp5y614zOTphcvFYhvUkCijQ6HT1TtRq/34SlFoRQqo4SFiLriK451xWIcfwiMLIekWrdoQa1v8dqIlMA3r6CKc0QykJpSYbiyormWiZ0hl2HLpkZ85mD9V0eDQ5RCtb6vkybK7INcq4yKQV4YkXhr9NpX9U4re4dlFQjEJQIDAQAB", "permissions": ["management", "storage", "alarms", "contextMenus", "downloads"], "host_permissions": ["https://clients2.google.com/service/*"], "optional_host_permissions": ["<all_urls>"], "action": {"default_icon": {"16": "assets/icon/icon_16.png", "24": "assets/icon/icon_24.png"}, "default_title": "Chromium Web Store", "default_popup": "popup.html#is_cws_popup"}, "content_scripts": [{"matches": ["https://chrome.google.com/webstore*", "https://addons.opera.com/*extensions/details/*", "https://microsoftedge.microsoft.com/addons/*"], "js": ["scripts/util.js", "scripts/inject.js"], "run_at": "document_end"}], "background": {"service_worker": "scripts/background.js"}, "update_url": "https://raw.githubusercontent.com/NeverDecaf/chromium-web-store/master/updates_en_nolocale.xml", "icons": {"16": "assets/icon/icon_16.png", "24": "assets/icon/icon_24.png", "32": "assets/icon/icon_32.png", "48": "assets/icon/icon_48.png", "64": "assets/icon/icon_64.png", "128": "assets/icon/icon_128.png"}, "homepage_url": "https://github.com/NeverDecaf/chromium-web-store", "options_ui": {"page": "options.html"}, "storage": {"managed_schema": "managed_storage.json"}}
6 changes: 6 additions & 0 deletions en_nolocale/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ <h2 data-localize="Update options">Update Options</h2>
</div>
<h2 data-localize="Ignored extensions">Ignored Extensions</h2>
<div id='updatetoggle'></div>
<h2 data-localize="Advanced">Advanced</h2>
<div>
<label title="Toggle this option if you are getting 'CRX_REQUIRED_PROOF_MISSING' errors">
<input type="checkbox" id="manually_install" /> <span data-localize="Always download CRX files">Always download CRX files</span>
</label>
</div>
<h2 data-localize="Import/Export">Import / Export</h2>
<div>
<textarea id="import_export_list"></textarea>
Expand Down
116 changes: 74 additions & 42 deletions en_nolocale/scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var extensionsDownloads = {};
var default_options = {
auto_update: true,
check_store_apps: true,
check_external_apps: true,
update_period_in_minutes: 60,
};
importScripts("./util.js");
const nonWebstoreExtensionsDownloading = new Set();
const manualInstallExtensionsDownloading = new Set();
const tabsAwaitingInstall = new Set();

const extensionsTabId = {};
function handleContextClick(info, tab) {
if (info.menuItemId == "updateAll")
checkForUpdates(function (
Expand All @@ -16,8 +12,8 @@ function handleContextClick(info, tab) {
updatever,
is_webstore
) {
let crx_url = updateCheck.getAttribute("codebase");
promptInstall(crx_url, is_webstore, extensionsDownloads);
let crx_url = updateCheck["@codebase"];
promptInstall(crx_url, is_webstore);
});
else if (info.menuItemId == "installExt")
chrome.tabs.sendMessage(tab.id, {
Expand All @@ -34,14 +30,14 @@ function updateBadge(modified_ext_id = null) {
}

function startupTasks() {
chrome.storage.sync.get(default_options, function (settings) {
chrome.storage.sync.get(DEFAULT_MANAGEMENT_OPTIONS, function (settings) {
chrome.storage.local.get(
{
badge_display: "",
last_scheduled_update: 0,
},
(localstore) => {
chrome.browserAction.setBadgeText({
chrome.action.setBadgeText({
text: localstore.badge_display,
});
chrome.alarms.create("cws_check_extension_updates", {
Expand All @@ -61,8 +57,8 @@ function startupTasks() {
);
});
}
chrome.browserAction.setBadgeBackgroundColor({
color: "#F00",
chrome.action.setBadgeBackgroundColor({
color: "#FE0000",
});
chrome.management.onInstalled.addListener(function (ext) {
updateBadge(ext.id);
Expand All @@ -87,30 +83,33 @@ chrome.runtime.onStartup.addListener(function () {
});
chrome.alarms.onAlarm.addListener(function (alarm) {
if (alarm.name == "cws_check_extension_updates")
chrome.storage.sync.get(default_options, function (settings) {
if (settings.auto_update) {
updateBadge();
chrome.storage.local.set({
last_scheduled_update: Date.now(),
});
chrome.alarms.create("cws_check_extension_updates", {
delayInMinutes: settings.update_period_in_minutes,
periodInMinutes: settings.update_period_in_minutes,
});
chrome.storage.sync.get(
DEFAULT_MANAGEMENT_OPTIONS,
function (settings) {
if (settings.auto_update) {
updateBadge();
chrome.storage.local.set({
last_scheduled_update: Date.now(),
});
chrome.alarms.create("cws_check_extension_updates", {
delayInMinutes: settings.update_period_in_minutes,
periodInMinutes: settings.update_period_in_minutes,
});
}
}
});
);
});
chrome.runtime.onInstalled.addListener(function () {
startupTasks();
chrome.contextMenus.create({
title: "Update all extensions",
id: "updateAll",
contexts: ["browser_action"],
contexts: ["action"],
});
chrome.contextMenus.create({
title: "🔗 Chrome Web Store",
id: "cws",
contexts: ["browser_action"],
contexts: ["action"],
});
chrome.contextMenus.create({
title: "Add to Chromium",
Expand All @@ -122,9 +121,27 @@ chrome.runtime.onInstalled.addListener(function () {
],
});
});
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.downloadId) {
extensionsDownloads[request.downloadId] = true;
const msgHandler = function (request, sender, sendResponse) {
if (request.nonWebstoreDownloadUrl) {
chrome.downloads.download(
{
url: request.nonWebstoreDownloadUrl,
},
(dlid) => {
nonWebstoreExtensionsDownloading.add(dlid);
}
);
}
if (request.manualInstallDownloadUrl) {
chrome.downloads.download(
{
url: request.manualInstallDownloadUrl,
saveAs: true, // required to suppress warning: "Apps, extensions and user scripts cannot be added from this website"
},
(dlid) => {
manualInstallExtensionsDownloading.add(dlid);
}
);
}
if (request.newTabUrl) {
chrome.tabs.create({ active: false }, (tab) => {
Expand All @@ -148,20 +165,35 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
if (request.installExt) {
tabsAwaitingInstall.add(sender.tab.id);
}
});
};
chrome.runtime.onMessage.addListener(msgHandler);
chrome.downloads.onChanged.addListener((d) => {
if (d.endTime && extensionsDownloads[d.id]) {
delete extensionsDownloads[d.id];
chrome.downloads.search(
{
id: d.id,
},
(di) => {
chrome.tabs.create({
url: "file:///" + di[0].filename,
// open chrome://extensions if user has "Always download CRX files" checked, for easy drag-and-drop installation
if (d.endTime && manualInstallExtensionsDownloading.has(d.id)) {
manualInstallExtensionsDownloading.delete(d.id);
chrome.tabs.get(extensionsTabId?.id ?? 0, (tab) => {
if (!chrome.runtime.lastError)
chrome.tabs.highlight({
tabs: tab.index,
windowId: tab.windowId,
});
}
);
else
chrome.tabs.create(
{
url: "chrome://extensions/",
},
(tab) => {
extensionsTabId.id = tab.id;
}
);
});
// chrome.notifications.create("manually_install", {
// type: "basic",
// iconUrl: "assets/icon/icon_128.png",
// title: "Extension downloaded! Please install manually:",
// message: "1. Enable Developer mode (top right)
2. Drag .crx from downloads bar onto extensions page",
// });
}
});
chrome.contextMenus.onClicked.addListener(handleContextClick);
74 changes: 25 additions & 49 deletions en_nolocale/scripts/inject.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const is_cws = /chrome.google.com\/webstore/i;
const is_ows = /addons.opera.com\/.*extensions/i;
const is_ews = /microsoftedge\.microsoft\.com\/addons\//i;
const is_ews_addon_page = /microsoftedge\.microsoft\.com\/addons\/detail\//i;
const cws_re = /.*detail\/[^\/]*\/([a-z]{32})/i;
const ows_re = /.*details\/([^\/?#]+)/i;
const ews_re = /.*addons\/.+?\/([a-z]{32})/i;
Expand Down Expand Up @@ -79,7 +78,7 @@ function createButton(newParent, addBtn = true) {
chrome.runtime.sendMessage({
installExt: getExtensionId(window.location.href),
});
window.open(dlurl);
promptInstall(dlurl, true);
} else {
chrome.runtime.sendMessage(
{
Expand Down Expand Up @@ -139,24 +138,27 @@ attachMainObserver = new MutationObserver(function (mutations, observer) {
if (is_ews.test(window.location.href)) {
new MutationObserver(function (mutations, observer) {
mutations.forEach(function (mutation) {
if (is_ews_addon_page.test(window.location.href)) {
let btn = mutation.target.querySelector("button[disabled]");
if (btn) {
mutation.target
.querySelectorAll('button[id^="getOrRemoveButton-"][disabled]')
.forEach((btn) => {
btn.classList.remove(
btn.className.split(" ").sort().reverse()[0]
btn.className
.split(" ")
.sort(
(a, b) =>
parseInt(b.slice(1)) - parseInt(a.slice(1))
)[btn.name == "GetButton" ? 1 : 0]
);
btn.removeAttribute("disabled");
btn.addEventListener("click", () => {
// normal methods fail because microsoft's official web store redirects you from HTTPS to an insecure HTTP url.
// instead use chrome.tabs to open the url in a new tab.
chrome.runtime.sendMessage({
newTabUrl: buildExtensionUrl(
getExtensionId(window.location.href)
),
});
promptInstall(
buildExtensionUrl(btn.id.split("-")[1]),
true,
WEBSTORE.edge
);
});
}
}
dlBtn = btn;
});
});
}).observe(document.body, {
childList: true,
Expand All @@ -179,30 +181,13 @@ if (is_ows.test(window.location.href)) {
dlBtn.innerHTML = "Add to Chromium";
sidebar.replaceChild(wrapper, installDiv);
wrapper.appendChild(dlBtn);
let url = buildExtensionUrl(getExtensionId(window.location.href));
function fetchExt() {
let filename = "ext.crx";
fetch(url)
.then((r) => {
r.headers.forEach((h) => {
let v = /filename=([^ ]+)/.exec(h);
if (v) {
filename = v[1];
return;
}
});
return r.blob();
})
.then((blob) => {
// set mime type to prevent automatic install; reference: https://stackoverflow.com/questions/57834691/how-to-serve-crx-file-in-a-way-that-is-not-automatically-installed
blob = blob.slice(0, blob.size, "application/zip");
const blobURL = window.URL.createObjectURL(blob);
dlBtn.href = blobURL;
dlBtn.download = filename;
dlBtn.click();
});
}
dlBtn.addEventListener("click", fetchExt, { once: true });
dlBtn.addEventListener("click", () =>
promptInstall(
buildExtensionUrl(getExtensionId(window.location.href)),
true,
WEBSTORE.opera
)
);
}
window.onload = () => {
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
Expand All @@ -212,16 +197,7 @@ window.onload = () => {
"opening extension URL:",
buildExtensionUrl(getExtensionId(window.location.href))
);
if (is_ows.test(window.location.href)) {
dlBtn.click();
} else if (
is_cws.test(window.location.href) ||
is_ews.test(window.location.href)
) {
window.open(
buildExtensionUrl(getExtensionId(window.location.href))
);
}
if (dlBtn) dlBtn.click();
break;
case "extInstalled":
if (request.extId == getExtensionId(window.location.href))
Expand Down
Loading

0 comments on commit ceffb30

Please sign in to comment.