Skip to content

Commit 43a9ae2

Browse files
committed
qute browser youtube adblock script
1 parent cd423b0 commit 43a9ae2

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

cfg/qutebrowser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,8 @@
19801980
c.url.start_pages = ['about:blank']
19811981
c.url.default_page = 'https://grok.com/'
19821982
c.url.searchengines = {
1983-
'DEFAULT': 'https://google.com/search?q=before:2023 {}',
1983+
'DEFAULT': 'https://google.com/search?q={}',
1984+
'old': 'https://google.com/search?q=before:2023 {}',
19841985
'ggl': 'https://google.com/search?q={}',
19851986
'ddg': 'https://duckduckgo.com/?q={}',
19861987
'gpt': 'https://chatgpt.com/?q={}',

nix/configuration.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
unst = import ./nixpkgs-unstable.nix;
1212
rocm = olds.rocmPackages_5;
1313
vibe = import ./vibe.nix {inherit pkgs;};
14+
qute = import ./qute.nix {inherit pkgs;};
1415
lockCmd = "${pkgs.swaylock}/bin/swaylock --color=000000";
1516
home-manager = builtins.fetchTarball {
1617
url = "https://github.com/nix-community/home-manager/archive/8d5e27b4807d25308dfe369d5a923d87e7dbfda3.tar.gz";
@@ -773,10 +774,10 @@ in {
773774
pulsemixer
774775
neovim
775776
vibe
777+
qute
776778
(import ./vidmaker.nix)
777779
(import ./clipmaker.nix)
778780
(import ./bar.nix {inherit pkgs;})
779-
(import ./qute.nix {inherit pkgs;})
780781
(import ./bip39-wordlist.nix)
781782
];
782783
programs.git = {
@@ -979,7 +980,7 @@ in {
979980
cfgProgrKeys = {
980981
"${mod}+Return" = "exec ${vibe}/bin/vibe";
981982
"${mod}+y" = "exec ${alacritty}/bin/alacritty -e ${pkgs.yewtube}/bin/yt";
982-
"${mod}+b" = "exec ${qutebrowser}/bin/qutebrowser";
983+
"${mod}+b" = "exec ${qute}/bin/qute";
983984
};
984985
cfgBasicKeys = {
985986
"Ctrl+Mod1+q" = wmEx lockCmd;

nix/qute.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@
1111
-C ${../cfg/qutebrowser.py} "$@"
1212
'';
1313
};
14+
ytb = pkgs.writeTextFile {
15+
name = "ytb.js";
16+
text = ''
17+
// ==UserScript==
18+
// @name Youtube Enhancements
19+
// @match *://*.youtube.com/*
20+
// ==/UserScript==
21+
22+
(function() {
23+
'use strict';
24+
25+
function skipAds() {
26+
const skipBtn = document.querySelector('.videoAdUiSkipButton, .ytp-ad-skip-button-modern, .ytp-skip-ad-button');
27+
if (skipBtn) skipBtn.click();
28+
const adVideo = document.querySelector('.ad-showing .video-stream');
29+
if (adVideo && adVideo.duration > 0 && adVideo.currentTime < adVideo.duration) {
30+
adVideo.currentTime = adVideo.duration;
31+
}
32+
}
33+
34+
function removeSponsored() {
35+
document.querySelectorAll('ytd-in-feed-ad-layout-renderer').forEach(el => el.remove());
36+
document.querySelectorAll('ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-ads"]').forEach(el => el.remove());
37+
}
38+
39+
function observer() {
40+
skipAds();
41+
removeSponsored();
42+
}
43+
44+
window.addEventListener('load', observer);
45+
new MutationObserver(observer).observe(document.body, { childList: true, subtree: true });
46+
})();
47+
'';
48+
};
1449
sandbox = mkNixPak {
1550
config = {sloth, ...}: {
1651
app.package = app;
@@ -23,6 +58,16 @@
2358
network = true;
2459
sockets.pulse = true;
2560
sockets.wayland = true;
61+
bind.ro = [
62+
[
63+
(toString ytb)
64+
(
65+
sloth.concat'
66+
sloth.homeDir
67+
"/.config/qutebrowser/greasemonkey/ytb.js"
68+
)
69+
]
70+
];
2671
bind.rw = [
2772
[
2873
(sloth.mkdir (sloth.concat' sloth.homeDir "/qute"))

0 commit comments

Comments
 (0)