Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video adblocker and unlock HD quality #52

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
"buildRetinaDMGBackground": "tiffutil -cathidpicheck background.png background@2x.png -out background.tiff"
},
"dependencies": {
"@cliqz/adblocker-electron": "^1.26.6",
"@types/express": "^4.17.13",
"@types/node": "^18.7.14",
"@types/peer-dial": "0.0.1",
"cross-fetch": "^4.0.0",
"express": "^4.17.1",
"hosted-git-info": "^5.1.0",
"lodash": "^4.17.21",
Expand All @@ -36,7 +38,9 @@
"productName": "YouTube TV",
"appId": "com.youtube.tv",
"asar": true,
"directories": { "output": "../YTV_Builds" },
"directories": {
"output": "../YTV_Builds"
},
"mac": {
"category": "public.app-category.entertainment",
"target": "dmg",
Expand All @@ -58,7 +62,10 @@
"background": "build/background.tiff"
},
"linux": {
"target": [ "deb", "rpm" ],
"target": [
"deb",
"rpm"
],
"icon": "build/icon.icns",
"packageCategory": "Video"
},
Expand Down
16 changes: 14 additions & 2 deletions renderers/main/main.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { platform } from 'os';
import { cwd } from 'process';
import { join } from 'path';
import { Settings } from '../settings/settings.renderer';
import { ElectronBlocker } from '@cliqz/adblocker-electron';
import fetch from 'cross-fetch';


import { app,
BrowserWindow,
nativeImage,
globalShortcut,
Menu,
ipcMain } from 'electron';
ipcMain,
session } from 'electron';

export interface resolution {

Expand All @@ -31,7 +35,7 @@ interface windowParams {
export class Renderer {

/** userAgent allowed by YouTube TV. */
private readonly userAgent: string = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.77 Large Screen Safari/534.24 GoogleTV/092754';
private readonly userAgent: string = 'Mozilla/5.0 (PS4; Leanback Shell) Gecko/20100101 Firefox/65.0 LeanbackShell/01.00.01.75 Sony PS4/ (PS4, , no, CH)';

/** Electron process */
private window: BrowserWindow;
Expand Down Expand Up @@ -60,6 +64,8 @@ export class Renderer {

this.createWindow();

this.injectBlocker();

this.listenWindowMoveEvents();

this.url = '__DFT__';
Expand Down Expand Up @@ -141,6 +147,12 @@ export class Renderer {
}
}

private injectBlocker() {
ElectronBlocker.fromPrebuiltAdsAndTracking(fetch).then((blocker) => {
blocker.enableBlockingInSession(session.defaultSession);
});
}

public setMaxRes(params: { width: number, height: number, reload: boolean }) {

const { width, height, reload } = params;
Expand Down