diff --git a/qutebrowser/.config/qutebrowser/greasemonkey/reddit_adblock.js b/qutebrowser/.config/qutebrowser/greasemonkey/reddit_adblock.js new file mode 100644 index 0000000..9b097d4 --- /dev/null +++ b/qutebrowser/.config/qutebrowser/greasemonkey/reddit_adblock.js @@ -0,0 +1,18 @@ +// ==UserScript== +// @name remove ads from reddit +// @version 1.0.0 +// @author afreakk +// @match *://*.reddit.com/* +// ==/UserScript== + +const removeShit = () => { + // promoted posts has this class + document.querySelectorAll('.promotedlink').forEach((e) => e.remove()); + // nagging about confirming email has this class + document + .querySelectorAll('.kEQVd8aneM1tVkcIKUyDT') + .forEach((e) => e.remove()); +}; +(trySetInterval = () => { + window.setInterval(removeShit, 1000); +})(); diff --git a/qutebrowser/.config/qutebrowser/greasemonkey/youtube.js b/qutebrowser/.config/qutebrowser/greasemonkey/youtube.js deleted file mode 100644 index e9c4826..0000000 --- a/qutebrowser/.config/qutebrowser/greasemonkey/youtube.js +++ /dev/null @@ -1,20 +0,0 @@ -// ==UserScript== -// https://www.reddit.com/r/qutebrowser/comments/u05nix/skipping_youtube_ads/ -// https://www.reddit.com/r/qutebrowser/comments/tue1gs/blocking_youtube_ads/ -// u/name Auto Skip YouTube Ads -// u/version 1.0.0 -// u/description Speed up and skip YouTube ads automatically -// u/author jso8910 -// u/match *://*.youtube.com/* -// u/exclude *://*.youtube.com/subscribe_embed?* -// ==/UserScript== -const btn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button') -if (btn) { - btn.click() -} - -const ad = [...document.querySelectorAll('.ad-showing')][0]; -if (ad) { - const vid = document.querySelector('video'); - vid.currentTime = vid.duration; -} diff --git a/qutebrowser/.config/qutebrowser/greasemonkey/youtube_adblock.js b/qutebrowser/.config/qutebrowser/greasemonkey/youtube_adblock.js new file mode 100644 index 0000000..f254c3c --- /dev/null +++ b/qutebrowser/.config/qutebrowser/greasemonkey/youtube_adblock.js @@ -0,0 +1,35 @@ +// ==UserScript== +// @name Skip youtube ads +// @version 1.0.0 +// @description Skips YouTube ads automatically +// @author afreakk +// @match *://*.youtube.com/* +// @exclude *://*.youtube.com/subscribe_embed?* +// ==/UserScript== +const skipAd = () => { + document + .querySelectorAll('.videoAdUiSkipButton,.ytp-ad-skip-button') + .forEach((b) => b.click()); + if (document.querySelector('.ad-showing')) { + document.querySelectorAll('video').forEach((v) => { + Number.isNaN(v.duration) || (v.currentTime = v.duration); + }); + } + document + .querySelectorAll('.ytd-display-ad-renderer#dismissible') + .forEach((el) => + // remove the ad video in top left of recommended + el?.parentElement?.parentElement?.parentElement?.remove?.() + ); + document + .querySelectorAll( + 'ytd-promoted-sparkles-web-renderer, #player-ads, #masthead-ad, ytd-compact-promoted-video-renderer' + ) + .forEach((el) => el.remove()); + document + .querySelectorAll('.ytd-mealbar-promo-renderer#dismiss-button') + .forEach((el) => el.click()); +}; +if (!window.skipAdIntervalID) { + window.skipAdIntervalID = setInterval(skipAd, 333); +} diff --git a/qutebrowser/.config/qutebrowser/greasemonkey/youtube_sponsorblock.js b/qutebrowser/.config/qutebrowser/greasemonkey/youtube_sponsorblock.js new file mode 100644 index 0000000..8d18b60 --- /dev/null +++ b/qutebrowser/.config/qutebrowser/greasemonkey/youtube_sponsorblock.js @@ -0,0 +1,41 @@ +// ==UserScript== +// @name Sponsorblock +// @version 1.0.0 +// @description Skip sponsor segments automatically +// @author afreakk +// @match *://*.youtube.com/* +// @exclude *://*.youtube.com/subscribe_embed?* +// ==/UserScript== +const tryFetchSkipSegments = (videoID) => + fetch(`https://sponsor.ajay.app/api/skipSegments?videoID=${videoID}`) + .then((r) => r.json()) + .then((rJson) => + rJson.filter((a) => a.actionType === 'skip').map((a) => a.segment) + ) + .catch( + (e) => + console.log( + `Sponsorblock: failed fetching skipSegments for ${videoID}, reason: ${e}` + ) || [] + ); + +const skipSegments = async () => { + const videoID = new URL(document.location).searchParams.get('v'); + if (!videoID) { + return; + } + const key = `segmentsToSkip-${videoID}`; + window[key] = window[key] || (await tryFetchSkipSegments(videoID)); + for (const v of document.querySelectorAll('video')) { + if (Number.isNaN(v.duration)) continue; + for (const [start, end] of window[key]) { + if (v.currentTime < end && v.currentTime > start) { + v.currentTime = end; + return console.log(`Sponsorblock: skipped video to ${end}`); + } + } + } +}; +if (!window.skipSegmentsIntervalID) { + window.skipSegmentsIntervalID = setInterval(skipSegments, 1000); +}