This commit is contained in:
Younes Aassila 2023-01-19 14:47:20 +01:00
parent 0ea6c64101
commit 6cebd58614
4 changed files with 22 additions and 55 deletions

View File

@ -65,7 +65,7 @@ This fork:
### Firefox (Recommended)
> ✅ The add-on updates automatically.
#### ✅ With Automatic Updates
1. Download the latest version of this extension in the "Releases" section (XPI file)
1. Go to `about:addons`
@ -74,7 +74,25 @@ This fork:
### Chrome
> ❌ The extension does not update automatically.
#### ✅ With Automatic Updates (Requires registry editing on Windows)
1. Download the latest version of this extension in the "Releases" section (CRX file) using the "Save link as…" button
1. Go to `chrome://extensions`
1. Turn on `Developer mode` (top right corner)
1. Drag and drop the CRX file you just downloaded into the extensions page (if an error occurs, restart your browser and try again)
1. Add this extension to your browser's allowlist (if you don't do this, the extension will be disabled at the next browser restart)
- For Windows users:
1. Open the registry editor (`regedit.exe`)
1. Create the following key (if it doesn't exist):
- `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallAllowlist` for Chrome
- `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallAllowlist` for Edge
- `HKEY_LOCAL_MACHINE\SOFTWARE\Policies\BraveSoftware\Brave\ExtensionInstallAllowlist` for Brave
1. Create a new `REG_SZ` (string) value named `1` (or any number) and set its value to `gfolbeacfbanmnohmnppjgenmmajffop` (the extension ID)
1. Restart your browser
- For Mac users: Look up how to allow local installations of extensions on Mac, or use the "Without Automatic Updates" method
- For Linux users: Chromium-based browsers on Linux allow local installations of extensions
#### ❌ Without Automatic Updates
1. Download the latest version of this extension in the "Releases" section (ZIP file)
1. Unzip the ZIP file you just downloaded

View File

@ -1,12 +1,7 @@
import browser from "webextension-polyfill";
import isChrome from "../common/ts/isChrome";
import onApiHeadersReceived from "./handlers/onApiHeadersReceived";
import onBeforeManifestRequest from "./handlers/onBeforeManifestRequest";
import onBeforeSendApiHeaders from "./handlers/onBeforeSendApiHeaders";
import onStartupUpdateCheck from "./handlers/onStartupUpdateCheck";
// Check for updates on Chrome startup.
if (isChrome) browser.runtime.onStartup.addListener(onStartupUpdateCheck);
// Redirect the HLS master manifest request to TTV LOL's API.
browser.webRequest.onBeforeRequest.addListener(

View File

@ -1,47 +0,0 @@
import semverCompare from "semver-compare";
import browser from "webextension-polyfill";
import store from "../../store";
//#region Types
type Update = {
version: string;
update_link: string;
};
//#endregion
export default async function onStartupUpdateCheck() {
if (store.readyState !== "complete") {
store.addEventListener("load", () => onStartupUpdateCheck());
return;
}
// If the last update check was less than 24 hours ago, don't check again.
if (
!store.state.isUpdateAvailable &&
Date.now() - store.state.lastUpdateCheck < 1000 * 60 * 60 * 24
) {
return;
}
const manifest = browser.runtime.getManifest();
const currentVersion = manifest.version;
const updateUrl = manifest.browser_specific_settings?.gecko?.update_url;
if (!updateUrl) {
store.state.isUpdateAvailable = false;
return;
}
try {
const response = await fetch(updateUrl);
const json = await response.json();
const updates = json.addons["{76ef94a4-e3d0-4c6f-961a-d38a429a332b}"]
.updates as Update[];
updates.sort((a, b) => semverCompare(a.version, b.version));
const latestVersion = updates[updates.length - 1].version;
store.state.isUpdateAvailable =
semverCompare(currentVersion, latestVersion) < 0; // currentVersion < latestVersion
store.state.lastUpdateCheck = Date.now();
} catch {
store.state.isUpdateAvailable = false;
}
}

View File

@ -41,5 +41,6 @@
"https://*.ttvnw.net/*",
"https://api.ttv.lol/*",
"https://www.twitch.tv/*"
]
],
"update_url": "https://younesaassila.github.io/ttv-lol-pro/updates.xml"
}