Skip to content

Commit

Permalink
Added updater
Browse files Browse the repository at this point in the history
  • Loading branch information
NeverDecaf committed Aug 19, 2019
1 parent 2c6a59f commit 6fcd758
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pem
*.pem
*.lnk
*.url
Binary file modified Chromium Web Store.crx
Binary file not shown.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# chromium-web-store
Allows adding extensions from chrome web store on unsupported chromium derivatives like ungoogled-chromium.
You can click the badge to check for updates to any web store extensions, it will also check automatically when you first start chromium.
If you wish to install the extensions directly instead of just downloading them, you must change the flag `chrome://flags/#extension-mime-request-handling` to `Always prompt for install`.
To install this extension, drag and drop the .crx into your `chrome://extensions` page.
Binary file added src/assets/icon/icon_128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon/icon_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon/icon_24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon/icon_32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon/icon_48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/icon/icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 28 additions & 8 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,40 @@
"author": "NeverDecaf",
"manifest_version": 2,
"name": "Chromium Web Store",
"version": "0.3",
"description": "Allow installing extensions from chrome web store on chromium based browsers.",
"background": { "scripts": ["background.js"] },
"version": "0.4",
"description": "Allow installing/updating extensions from chrome web store on chromium based browsers. Click badge to check for updates.",
"permissions" : [
"management", "https://clients2.google.com/service/*"
],
"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/*"],
"js": ["background.js"],
"js": ["store.js"],
"run_at": "document_start"
}
],
"web_accessible_resources": [
"inject.js"
],
"update_url": "https://raw.githubusercontent.com/NeverDecaf/chromium-web-store/master/updates.xml"
"background": {
"scripts": ["startup.js"],
"persistent": false
},
"web_accessible_resources": [
"inject.js"
],
"update_url": "https://raw.githubusercontent.com/NeverDecaf/chromium-web-store/master/updates.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"
}
}
10 changes: 10 additions & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Store Updates</title>
<script src="popup.js"></script>
</head>
<body style="white-space: nowrap;">
</body>
</html>
51 changes: 51 additions & 0 deletions src/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

chrome.management.getAll(function (e) {
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion='+chromeVersion;
var installed_versions = {};
e.forEach(function(ex) {
updateUrl += '&x=id%3D'+ex.id+'%26uc';
installed_versions[ex.id] = ex;
});
document.body.innerHTML = '<h3>Checking for updates...</h3>';
var resulthtml = '<h3>Available Updates:</h3>';
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
xmlDoc = this.responseXML;
var updates = xmlDoc.getElementsByTagName('app');
console.log(updates);
var updatecount = 0;
for (var i=0; i < updates.length; i++) {
if (updateCheck = updates[i].firstChild) {
var appid = updates[i].getAttribute('appid');

if (updateCheck.getAttribute('version') && installed_versions[appid].version != updateCheck.getAttribute('version'))
{
resulthtml+='<div display="inline">';
resulthtml+='<a href="https://chrome.google.com/webstore/detail/'+appid+'" target="_blank">'+installed_versions[appid].name+' ('+installed_versions[appid].version+' => '+updateCheck.getAttribute('version')+')</a>';
resulthtml+='</div>';
updatecount++;
}
}
}
if (updatecount > 0)
{
chrome.browserAction.setBadgeText({text: ''+updatecount});
document.body.innerHTML = resulthtml;
}
else {
chrome.browserAction.setBadgeText({text: ''});
document.body.innerHTML = '<h3>All web store extensions up to date!</h3>';
}
}
else {
chrome.browserAction.setBadgeText({text: "?"});
document.body.innerHTML = '<h3>Update check failed!</h3>';
}
}
};
xhttp.open("GET", updateUrl, true);
xhttp.send();
});
50 changes: 50 additions & 0 deletions src/startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
updateBadge();

function updateBadge (modified_ext_id = null) {
chrome.management.getAll(function (e) {
var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];
var updateUrl = 'https://clients2.google.com/service/update2/crx?response=updatecheck&acceptformat=crx2,crx3&prodversion='+chromeVersion;
var installed_versions = {};
chrome.browserAction.setBadgeBackgroundColor({color:'#F00'});
e.forEach(function(ex) {
updateUrl += '&x=id%3D'+ex.id+'%26uc';
installed_versions[ex.id] = ex;
});
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4) {
if (this.status == 200) {
xmlDoc = this.responseXML;
var updates = xmlDoc.getElementsByTagName('app');
var updatecount = 0;
for (var i=0; i < updates.length; i++) {
if (updateCheck = updates[i].firstChild) {
var appid = updates[i].getAttribute('appid');
if (appid != modified_ext_id && updateCheck.getAttribute('version') && installed_versions[appid].version != updateCheck.getAttribute('version'))
{
updatecount++;
}
}
}
if (updatecount > 0)
chrome.browserAction.setBadgeText({text: ''+updatecount});
else
chrome.browserAction.setBadgeText({text: ''});
}
else {
chrome.browserAction.setBadgeText({text: "?"});
}
}
};
xhttp.open("GET", updateUrl, true);
xhttp.send();
});
};

chrome.management.onInstalled.addListener(function(ext) {
updateBadge(ext.id);
});

chrome.management.onUninstalled.addListener(function(ext) {
updateBadge(ext.id);
});
File renamed without changes.
2 changes: 1 addition & 1 deletion updates.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='ocaahdebbfolfmndjeplogmgcagdmblk'>
<updatecheck codebase='https://github.com/NeverDecaf/chromium-web-store/releases/latest/download/Chromium.Web.Store.crx' version='0.3' />
<updatecheck codebase='https://github.com/NeverDecaf/chromium-web-store/releases/latest/download/Chromium.Web.Store.crx' version='0.4' />
</app>
</gupdate>

0 comments on commit 6fcd758

Please sign in to comment.