Skip to content

Commit

Permalink
add option to ignore specific extensions, closes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverDecaf committed Nov 28, 2019
1 parent 385cdb8 commit 36fd9e8
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 144 deletions.
Binary file modified Chromium Web Store.crx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "NeverDecaf",
"manifest_version": 2,
"name": "Chromium Web Store",
"version": "0.7.1",
"version": "0.8.0",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqF/d41Q7agjkUzYq8ZGbQr8XW8mmEIMXOnR1uCTnYLL+Dm9Z+LO50xZukOISNy6zFxpI8ts/OGLsm+I2x9+UprUU4/EVdmxuwegFE6NBoEhHoRNYY0gbXZkaU8YY/XwzjVY/k18DDhl5NYPEnF6uq4Oyidg+xtd3W4+iGYczuOLER1Tp5y614zOTphcvFYhvUkCijQ6HT1TtRq/34SlFoRQqo4SFiLriK451xWIcfwiMLIekWrdoQa1v8dqIlMA3r6CKc0QykJpSYbiyormWiZ0hl2HLpkZ85mD9V0eDQ5RCtb6vkybK7INcq4yKQV4YkXhr9NpX9U4re4dlFQjEJQIDAQAB",
"description": "Allow installing/updating extensions from chrome web store on chromium based browsers. Click badge to check for updates.",
"permissions": [
Expand Down
4 changes: 3 additions & 1 deletion src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ <h2>Update Options</h2>
<input type="checkbox" id="check_external_apps"/> <span>Check for updates to non-web store extensions</span>
</label>
</div>
<h2>Ignored Extensions</h2>
<div id='updatetoggle'></div>
</div>
<script src="scripts/options.js"></script>
<script src="scripts/options.js"></script>

This comment has been minimized.

Copy link
@mikhaelkh

mikhaelkh Nov 28, 2019

Both tabs and spaces are used in this file.

This comment has been minimized.

Copy link
@krystian3w

krystian3w Nov 30, 2019

this no kill CPU/RAM.

</body>
</html>
200 changes: 107 additions & 93 deletions src/scripts/background.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,102 @@
chrome.browserAction.setBadgeBackgroundColor({
color: '#F00'
});

function updateBadge(modified_ext_id = null) {
chrome.storage.sync.get({
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
}, function (settings) {
if (settings.auto_update) {
chrome.management.getAll(function (e) {
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var webstoreUrl = 'clients2.google.com/service/update2/crx';
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion=' + chromeVersion;
var installed_versions = {};
var updateUrls = [];
e.forEach(function (ex) {
if (ex.updateUrl) {
if (webstoreUrl == ex.updateUrl.replace(/^(?:https?:\/\/)?/i, "")) {
updateUrl += '&x=id%3D' + ex.id + '%26uc';
} else {
updateUrls.push(ex.updateUrl);
}
installed_versions[ex.id] = ex;
}
});
updateUrls.push(updateUrl);
chrome.management.getAll(function (e) {
var default_options = {
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
};
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var webstoreUrl = 'clients2.google.com/service/update2/crx';
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion=' + chromeVersion;
var installed_versions = {};
var updateUrls = [];
e.forEach(function (ex) {
if (ex.updateUrl) {
if (webstoreUrl == ex.updateUrl.replace(/^(?:https?:\/\/)?/i, "")) {
updateUrl += '&x=id%3D' + ex.id + '%26uc';
} else {
updateUrls.push(ex.updateUrl);
}
installed_versions[ex.id] = ex;
}
default_options[ex.id] = false;
});
updateUrls.push(updateUrl);

function getNewXhr() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
xmlDoc = this.responseXML;
var updates = xmlDoc.getElementsByTagName('app');
let updateCount = 0;
for (var i = 0; i < updates.length; i++) {
if (updateCheck = updates[i].querySelector("*")) {
var updatever = updateCheck.getAttribute('version');
var appid = updates[i].getAttribute('appid');
var is_webstore = xhttp._url == updateUrl;
if (updatever && installed_versions[appid].version != updatever) {
updateCount++;
chrome.storage.sync.get(default_options, function (settings) {
if (settings.auto_update) {
function getNewXhr() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4) {
if (this.status == 200) {
xmlDoc = this.responseXML;
var updates = xmlDoc.getElementsByTagName('app');
let updateCount = 0;
for (var i = 0; i < updates.length; i++) {
if (updateCheck = updates[i].querySelector("*")) {
var updatever = updateCheck.getAttribute('version');
var appid = updates[i].getAttribute('appid');
var is_webstore = xhttp._url == updateUrl;
if (updatever && !settings[appid] && installed_versions[appid].version != updatever) {
updateCount++;
}
}
}
}
chrome.browserAction.getBadgeText({}, function (currentText) {
if (currentText != '?') {
if (!currentText) {
if (updateCount)
chrome.browserAction.getBadgeText({}, function (currentText) {
if (currentText != '?') {
if (!currentText) {
if (updateCount)
chrome.browserAction.setBadgeText({
text: '' + updateCount
});
} else
chrome.browserAction.setBadgeText({
text: '' + updateCount
text: parseInt(updateCount) + parseInt(currentText) + ''
});
} else
chrome.browserAction.setBadgeText({
text: parseInt(updateCount) + parseInt(currentText) + ''
});
}
});
} else {
if (is_webstore)
chrome.browserAction.setBadgeText({
text: "?"
}
});
} else {
if (is_webstore)
chrome.browserAction.setBadgeText({
text: "?"
});
}
}
}
};
xhttp.overrideMimeType('application/xml');
return xhttp;
};
xhttp.overrideMimeType('application/xml');
return xhttp;
};
chrome.browserAction.setBadgeText({
text: ''
});
updateUrls.forEach(function (uurl) {
if ((updateUrl == uurl && settings.check_store_apps) || (updateUrl != uurl && settings.check_external_apps)) {
xhr = getNewXhr();
xhr.open("GET", uurl, true);
xhr._url = uurl;
xhr.send();
}
});
});
}
chrome.browserAction.setBadgeText({
text: ''
});
updateUrls.forEach(function (uurl) {
if ((updateUrl == uurl && settings.check_store_apps) || (updateUrl != uurl && settings.check_external_apps)) {
xhr = getNewXhr();
xhr.open("GET", uurl, true);
xhr._url = uurl;
xhr.send();
}
});
}
});
});
};
chrome.management.onInstalled.addListener(function (ext) {
updateBadge(ext.id);
console.log(ext);
});
chrome.management.onEnabled.addListener(function (ext) {
console.log("enabled");
console.log(ext);
});
chrome.management.onDisabled.addListener(function (ext) {
console.log("disabled");
console.log(ext);
});
chrome.management.onUninstalled.addListener(function (ext) {
updateBadge(ext.id);
Expand All @@ -102,29 +114,31 @@ chrome.alarms.onAlarm.addListener(function (alarm) {

function updateAll(info) {
if (info.menuItemId == 'updateAll') {
chrome.storage.sync.get({
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
}, function (settings) {
chrome.management.getAll(function (e) {
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var webstoreUrl = 'clients2.google.com/service/update2/crx';
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion=' + chromeVersion;
var installed_versions = {};
var updateUrls = [];
e.forEach(function (ex) {
if (ex.updateUrl) {
if (webstoreUrl == ex.updateUrl.replace(/^(?:https?:\/\/)?/i, "")) {
updateUrl += '&x=id%3D' + ex.id + '%26uc';
} else {
updateUrls.push(ex.updateUrl);
}
installed_versions[ex.id] = ex;
chrome.management.getAll(function (e) {
var default_options = {
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
};
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var webstoreUrl = 'clients2.google.com/service/update2/crx';
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion=' + chromeVersion;
var installed_versions = {};
var updateUrls = [];
e.forEach(function (ex) {
if (ex.updateUrl) {
if (webstoreUrl == ex.updateUrl.replace(/^(?:https?:\/\/)?/i, "")) {
updateUrl += '&x=id%3D' + ex.id + '%26uc';
} else {
updateUrls.push(ex.updateUrl);
}
});
updateUrls.push(updateUrl);
installed_versions[ex.id] = ex;
}
default_options[ex.id] = false;
});
updateUrls.push(updateUrl);

chrome.storage.sync.get(default_options, function (settings) {
function getNewXhr() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
Expand All @@ -138,7 +152,7 @@ function updateAll(info) {
var updatever = updateCheck.getAttribute('version');
var appid = updates[i].getAttribute('appid');
var is_webstore = xhttp._url == updateUrl;
if (updatever && installed_versions[appid].version != updatever) {
if (updatever && !settings[appid] && installed_versions[appid].version != updatever) {
updateCount++;
let crx_url = updateCheck.getAttribute('codebase');
window.open(crx_url, '_blank');
Expand Down
69 changes: 47 additions & 22 deletions src/scripts/options.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
const default_options = {
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
};
function restore_options() {
chrome.storage.sync.get(default_options, function (items) {
console.log(items);
for (const [setting, checked] of Object.entries(items)) {
let node = document.getElementById(setting);
node.checked = checked;
node.addEventListener("click", e => {
const checked = e.target.checked;
chrome.storage.sync.set({
[e.target.id]: checked
}, function () {
if (chrome.runtime.lastError) {
node.checked = !checked;
}
function load_options() {
var maindiv = document.getElementById('updatetoggle');
var default_options = {
"auto_update": true,
"check_store_apps": true,
"check_external_apps": true
};
chrome.management.getAll(function (e) {
e.forEach(function (ex) {
label = document.createElement('label');
label.setAttribute('title', 'Never check for updates to this extension');
span = document.createElement('span');
div = document.createElement('div');
img = document.createElement('img');
input = document.createElement('input');
input.setAttribute('type', 'checkbox');
input.setAttribute('id', ex.id);
img.setAttribute('alt', ex.name);
if (ex.icons)
img.setAttribute('src', 'chrome://extension-icon/' + ex.id + '/' + ex.icons[0].size + '/0');
else
img.setAttribute('src', 'chrome://extension-icon/' + ex.id + '/16/0');
span.innerHTML = ex.name;
label.appendChild(input);
label.appendChild(img);
label.appendChild(span);
div.appendChild(label);
maindiv.appendChild(div);
default_options[ex.id] = false;
});
chrome.storage.sync.get(default_options, function (items) {
for (const [setting, checked] of Object.entries(items)) {
let node = document.getElementById(setting);
node.checked = checked;
node.addEventListener("click", e => {
const checked = e.target.checked;
chrome.storage.sync.set({
[e.target.id]: checked
}, function () {
if (chrome.runtime.lastError) {
node.checked = !checked;
}
});
});
});
}
}
});
});
}
document.addEventListener('DOMContentLoaded', restore_options);

document.addEventListener('DOMContentLoaded', load_options);
Loading

0 comments on commit 36fd9e8

Please sign in to comment.