-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Bellisario/auto-update-dev
Update Check
- Loading branch information
Showing
7 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
if (chrome) | ||
var browser = chrome; | ||
|
||
var debug = false; | ||
|
||
(async function () { | ||
var version = await fetch(browser.runtime.getURL('version.txt')); | ||
version = await version.text(); | ||
if (version.includes('default') && debug === false) | ||
return console.log('Not checking for updates:\nChromeTemp is running from source (dev mode).'); | ||
console.log('Checking for updates...'); | ||
var latest = await fetch('https://github.com/Bellisario/ChromeTemp/releases/latest'); | ||
latest = latest.url.replace('https://github.com/Bellisario/ChromeTemp/releases/tag/', ''); | ||
console.log('Current version:', version, '\nLatest version:', latest); | ||
if (!version.includes(latest)) { | ||
console.log('Update available.'); | ||
await new Promise(r => setTimeout(r, 10000)); | ||
notification = browser.notifications.create('chrome-temp.updater', { | ||
title: 'ChromeTemp Update Available', | ||
message: 'Click here to open the download page.', | ||
iconUrl: browser.runtime.getURL('chrome-temp.png'), | ||
type: 'basic', | ||
requireInteraction: true | ||
}); | ||
browser.notifications.onClicked.addListener(function () { | ||
browser.notifications.clear('chrome-temp.updater'); | ||
browser.tabs.create({url: 'https://github.com/Bellisario/ChromeTemp/releases/latest'}); | ||
}); | ||
} else { | ||
console.log('No update found.'); | ||
}; | ||
})(); | ||
|
||
browser.browserAction.onClicked.addListener(function () { | ||
browser.tabs.create({ | ||
url: 'https://github.com/Bellisario/ChromeTemp/releases/latest' | ||
}); | ||
}); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "ChromeTemp Updater", | ||
"description": "This is the update checker of ChromeTemp.", | ||
"version": "1.0", | ||
"permissions": [ | ||
"tabs", | ||
"activeTab", | ||
"webRequest", | ||
"notifications", | ||
"<all_urls>" | ||
], | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"browser_action": { | ||
"default_title": "" | ||
}, | ||
"manifest_version": 2, | ||
"icons": { | ||
"128": "chrome-temp.png" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters