|
1 |
| -// TODO [#25]: Check the whitelist to see if youtube has been whitelisted |
2 | 1 | // Note that google really doesn't want ads blocked on youtube, hence why
|
3 | 2 | // the default adblock behavior doesn't work properly. Instead we need to create
|
4 | 3 | // a custom blocker that stops ads from being displayed. A really simple bodge
|
5 | 4 | // is to just click the skip button instantly and seem like we have properly skipped
|
6 | 5 | // the ad. The skip button ad is currently .ytp-ad-text.ytp-ad-skip-button-text
|
7 | 6 |
|
8 |
| -setInterval(() => { |
9 |
| - // Grab the skip button |
10 |
| - const skipButton: HTMLDivElement = document.querySelector( |
11 |
| - '.ytp-ad-text.ytp-ad-skip-button-text' |
12 |
| - ) |
| 7 | +import { remoteFn } from '../lib/remoteFunctions' |
| 8 | + |
| 9 | +// Needs to be in an async block to get the whitelist |
| 10 | +;(async () => { |
| 11 | + const whitelist = await remoteFn('getWhitelist') |
| 12 | + if (whitelist.includes('youtube.com')) return |
13 | 13 |
|
14 |
| - // If the skip button does exists |
15 |
| - if (skipButton) { |
16 |
| - // Lets "smash that skip button" |
17 |
| - skipButton.click() |
18 |
| - // TODO [#26]: Automatically remove console.log's in production |
19 |
| - // Provide feedback in the console |
20 |
| - console.log('Video was skipped') |
21 |
| - } |
22 |
| -}, 100) |
| 14 | + setInterval(() => { |
| 15 | + // Grab the skip button |
| 16 | + const skipButton: HTMLDivElement = document.querySelector( |
| 17 | + '.ytp-ad-text.ytp-ad-skip-button-text' |
| 18 | + ) |
23 | 19 |
|
24 |
| -console.log( |
25 |
| - '================================\nDot Shield is enabled on youtube.com\nWe will try to block all ads on this webpage' |
26 |
| -) |
| 20 | + // If the skip button does exists |
| 21 | + if (skipButton) { |
| 22 | + // Lets "smash that skip button" |
| 23 | + skipButton.click() |
| 24 | + // TODO [#26]: Automatically remove console.log's in production |
| 25 | + // Provide feedback in the console |
| 26 | + console.log('Video was skipped') |
| 27 | + } |
| 28 | + }, 100) |
| 29 | + |
| 30 | + console.log( |
| 31 | + '================================\nDot Shield is enabled on youtube.com\nWe will try to block all ads on this webpage' |
| 32 | + ) |
| 33 | +})() |
0 commit comments