diff --git a/Chromium Web Store.crx b/Chromium Web Store.crx index fbe4be7..ece70eb 100644 Binary files a/Chromium Web Store.crx and b/Chromium Web Store.crx differ diff --git a/src/manifest.json b/src/manifest.json index 914d77a..a8e1a09 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -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": [ diff --git a/src/options.html b/src/options.html index a967be6..ae36451 100644 --- a/src/options.html +++ b/src/options.html @@ -23,7 +23,9 @@

Update Options

Check for updates to non-web store extensions +

Ignored Extensions

+
- + \ No newline at end of file diff --git a/src/scripts/background.js b/src/scripts/background.js index bd21f10..e563354 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -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); @@ -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 () { @@ -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'); diff --git a/src/scripts/options.js b/src/scripts/options.js index 05b5c7c..d986b40 100644 --- a/src/scripts/options.js +++ b/src/scripts/options.js @@ -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); \ No newline at end of file + +document.addEventListener('DOMContentLoaded', load_options); \ No newline at end of file diff --git a/src/scripts/popup.js b/src/scripts/popup.js index c48ef03..c4f5824 100644 --- a/src/scripts/popup.js +++ b/src/scripts/popup.js @@ -7,30 +7,33 @@ var alluptodate = document.createElement('h1'); alluptodate.innerHTML = 'Checking for updates...'; container.appendChild(alluptodate); container.appendChild(appcontainer); -chrome.storage.sync.get({ - "auto_update": true, - "check_store_apps": true, - "check_external_apps": true -}, function (settings) { - if (!settings.check_store_apps && !settings.check_external_apps) - alluptodate.innerHTML = 'All extensions are up to date!'; - 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) { + if (!settings.check_store_apps && !settings.check_external_apps) + alluptodate.innerHTML = 'All extensions are up to date!'; + function getNewXhr() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function () { @@ -44,7 +47,7 @@ chrome.storage.sync.get({ 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++; var li = document.createElement('li'); li.setAttribute('data-enabled', installed_versions[appid].enabled ? 'true' : 'false'); @@ -70,7 +73,7 @@ chrome.storage.sync.get({ li.appendChild(storepage); } li.setAttribute('crx_url', updateCheck.getAttribute('codebase')); - let crx_url = updateCheck.getAttribute('codebase'); + let crx_url = updateCheck.getAttribute('codebase'); li.addEventListener("click", function (evt) { if (evt.target.tagName != 'A') window.open(crx_url); @@ -80,7 +83,6 @@ chrome.storage.sync.get({ } } } - chrome.browserAction.getBadgeText({}, function (currentText) { if (currentText != '?') { if (!currentText) { @@ -121,6 +123,8 @@ chrome.storage.sync.get({ if (completed == 0) alluptodate.innerHTML = 'All extensions are up to date!'; }; + } else { + completed--; } }); }); diff --git a/src/sheets/options.css b/src/sheets/options.css index 63519a9..8a3cdff 100644 --- a/src/sheets/options.css +++ b/src/sheets/options.css @@ -22,3 +22,10 @@ label > span { margin-left: 0.3em; user-select: none; } + +label > img { + flex: 0 0 auto; + margin: auto 4px auto 8px; + width: 16px; + height: 16px; +} \ No newline at end of file diff --git a/updates.xml b/updates.xml index 38dddcb..177e96a 100644 --- a/updates.xml +++ b/updates.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file