Skip to content

Commit

Permalink
🔀 Merge pull request #57 from younesaassila/v1.7.1
Browse files Browse the repository at this point in the history
🔖 Release version 1.7.1
  • Loading branch information
younesaassila authored Jan 19, 2023
2 parents df36ee2 + c3ce265 commit 7895c0e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 107 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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…` right-click option
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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ttv-lol-pro",
"version": "1.7.0",
"version": "1.7.1",
"description": "TTV LOL PRO removes livestream ads from Twitch",
"@parcel/bundler-default": {
"minBundles": 10000000,
Expand Down
5 changes: 0 additions & 5 deletions src/background/background.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
9 changes: 3 additions & 6 deletions src/background/handlers/onBeforeManifestRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,13 @@ export default function onBeforeManifestRequest(
} catch {}

if (token) {
// No redirect if the user is a subscriber, has Twitch Turbo, or is a partner.
const isPremiumUser =
token.subscriber === true ||
token.turbo === true ||
token.partner === true;
// No redirect if the user is a subscriber or has Twitch Turbo.
const isExemptFromAds = token.subscriber === true || token.turbo === true;
const isIgnoredChannelSubscription =
store.state.ignoredChannelSubscriptions.some(
channel => channel.toLowerCase() === channelName
);
if (isPremiumUser && !isIgnoredChannelSubscription) {
if (isExemptFromAds && !isIgnoredChannelSubscription) {
console.log(
`${streamId}: No redirect (User is a subscriber, has Twitch Turbo, or is a partner)`
);
Expand Down
47 changes: 0 additions & 47 deletions src/background/handlers/onStartupUpdateCheck.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "TTV LOL PRO",
"description": "TTV LOL PRO removes livestream ads from Twitch.",
"version": "1.7.0",
"version": "1.7.1",
"background": {
"persistent": true,
"scripts": ["background/background.ts"]
Expand Down Expand Up @@ -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"
}
8 changes: 5 additions & 3 deletions src/options/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ exportButtonElement.addEventListener("click", () => {
saveFile(
"ttv-lol-pro_backup.json",
JSON.stringify({
...store.state,
isUpdateAvailable: undefined,
lastUpdateCheck: undefined,
disableVodRedirect: store.state.disableVodRedirect,
ignoredChannelSubscriptions: store.state.ignoredChannelSubscriptions,
resetPlayerOnMidroll: store.state.resetPlayerOnMidroll,
servers: store.state.servers,
whitelistedChannels: store.state.whitelistedChannels,
}),
"application/json;charset=utf-8"
);
Expand Down
1 change: 0 additions & 1 deletion src/options/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ <h2>Privacy</h2>
<label for="disable-vod-redirect-checkbox">
Disable VOD proxying
</label>
<span class="tag">Recommended</span>
<br />
<small>
TTV LOL's API requires your Twitch token (containing sensitive
Expand Down
13 changes: 8 additions & 5 deletions src/page/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace TTV_LOL_PRO {
}

// From https://github.com/cleanlock/VideoAdBlockForTwitch/blob/145921a822e830da62d39e36e8aafb8ef22c7be6/chrome/remove_video_ads.js#L296-L301
function getWasmWorkerUrl(twitchBlobUrl: string | URL) {
function getWasmWorkerUrl(twitchBlobUrl: string | URL): string | undefined {
const request = new XMLHttpRequest();
request.open("GET", twitchBlobUrl, false);
request.send();
Expand Down Expand Up @@ -202,14 +202,17 @@ namespace TTV_LOL_PRO {
export class Worker extends REAL_WORKER {
constructor(twitchBlobUrl: string | URL) {
const urlString = twitchBlobUrl.toString();
const isValidBlobUrl = /^(blob|https?):/i.test(urlString);
log(`Worker URL: ${urlString}`);
const isValidBlobUrl = urlString.toLowerCase().startsWith("blob:");
log(`Twitch blob URL: ${urlString}`);
if (twitchMainWorker != null || !isValidBlobUrl) {
super(twitchBlobUrl);
return;
}
const jsURL = getWasmWorkerUrl(twitchBlobUrl);
if (typeof jsURL !== "string") {
const isValidJsUrl =
typeof jsURL === "string" && jsURL.toLowerCase().startsWith("https:");
log(`WASM worker URL: ${jsURL}`);
if (!isValidJsUrl) {
super(twitchBlobUrl);
return;
}
Expand All @@ -220,7 +223,7 @@ namespace TTV_LOL_PRO {
` as BlobPart;
super(URL.createObjectURL(new Blob([blobPart])));
twitchMainWorker = this;
log("Listening for video-weaver requests…");
log("Successfully hooked into Twitch's main worker.");
// Listen for messages from the worker.
this.addEventListener("message", event => {
switch (event.data?.type) {
Expand Down
2 changes: 1 addition & 1 deletion src/store/getDefaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function getDefaultState() {
ignoredChannelSubscriptions: [],
isUpdateAvailable: false,
lastUpdateCheck: 0,
resetPlayerOnMidroll: true,
resetPlayerOnMidroll: false,
servers: ["https://api.ttv.lol"],
streamStatuses: {},
whitelistedChannels: [],
Expand Down
32 changes: 0 additions & 32 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,8 @@
//#region Helpers

// From https://stackoverflow.com/a/51419293
export type KeyOfType<T, V> = keyof {
[P in keyof T as T[P] extends V ? P : never]: any;
};

//#endregion

//#region Message

type MessageType = "midroll";

export interface Message {
type: MessageType;
request?: Record<string | symbol, any>;
response?: Record<string | symbol, any>;
}

export interface MidrollMessage extends Message {
type: "midroll";
response: {
tabId: number;
startDateString: string;
};
}

//#endregion

//#region Stream Status

export interface StreamStatus {
redirected: boolean;
reason: string;
Expand All @@ -41,10 +15,6 @@ export interface StreamStatusError {
status: number;
}

//#endregion

//#region API

export const enum PlaylistType {
Playlist = "playlist",
VOD = "vod",
Expand Down Expand Up @@ -89,5 +59,3 @@ export interface Token {
version: number;
vod_id?: number;
}

//#endregion

0 comments on commit 7895c0e

Please sign in to comment.