aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qute/dot-config/qutebrowser/autoconfig.yml34
-rw-r--r--qute/dot-config/qutebrowser/config.py8
-rw-r--r--qute/dot-config/qutebrowser/greasemonkey/yt-ads.js226
3 files changed, 19 insertions, 249 deletions
diff --git a/qute/dot-config/qutebrowser/autoconfig.yml b/qute/dot-config/qutebrowser/autoconfig.yml
deleted file mode 100644
index 46b73d3..0000000
--- a/qute/dot-config/qutebrowser/autoconfig.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-# If a config.py file exists, this file is ignored unless it's explicitly loaded
-# via config.load_autoconfig(). For more information, see:
-# https://github.com/qutebrowser/qutebrowser/blob/main/doc/help/configuring.asciidoc#loading-autoconfigyml
-# DO NOT edit this file by hand, qutebrowser will overwrite it.
-# Instead, create a config.py - see :help for details.
-
-config_version: 2
-settings:
- content.blocking.hosts.lists:
- global:
- - https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
- content.headers.user_agent:
- https://accounts.google.com/*: Mozilla/5.0 ({os_info}; rv:131.0) Gecko/20100101
- Firefox/131.0
- content.javascript.clipboard:
- https://github.com: access-paste
- content.notifications.enabled:
- https://web.whatsapp.com: true
- content.register_protocol_handler:
- https://calendar.google.com?cid=%25s: true
- https://outlook.office.com?mailtouri=%25s: false
- content.user_stylesheets:
- global: null
- downloads.location.suggestion:
- global: both
- spellcheck.languages:
- global:
- - en-US
- tabs.last_close:
- global: close
- url.default_page:
- global: file:///home/moreka/.config/qutebrowser/startpage.html
- url.start_pages:
- global: file:///home/moreka/.config/qutebrowser/startpage.html
diff --git a/qute/dot-config/qutebrowser/config.py b/qute/dot-config/qutebrowser/config.py
index 54f3f6d..0ec21a5 100644
--- a/qute/dot-config/qutebrowser/config.py
+++ b/qute/dot-config/qutebrowser/config.py
@@ -10,6 +10,9 @@ c.url.searchengines = {
"!yt": "https://www.youtube.com/results?search_query={}",
}
+c.url.default_page = "file:///home/moreka/.config/qutebrowser/startpage.html"
+c.url.start_pages = ["file:///home/moreka/.config/qutebrowser/startpage.html"]
+
c.completion.open_categories = [
"searchengines",
"quickmarks",
@@ -21,6 +24,11 @@ c.completion.open_categories = [
c.new_instance_open_target = "tab-bg"
c.tabs.show = "multiple"
+c.tabs.last_close = "close"
+
+c.downloads.location.suggestion = "both"
+
+c.spellcheck.languages = ["en-US"]
config.load_autoconfig() # load settings done via the gui
diff --git a/qute/dot-config/qutebrowser/greasemonkey/yt-ads.js b/qute/dot-config/qutebrowser/greasemonkey/yt-ads.js
index db98c6b..788734f 100644
--- a/qute/dot-config/qutebrowser/greasemonkey/yt-ads.js
+++ b/qute/dot-config/qutebrowser/greasemonkey/yt-ads.js
@@ -7,221 +7,17 @@
// @match *://*.youtube.com/*
// ==/UserScript==
-// NOTE: this is the previous version I had
-// document.addEventListener('load', () => {
-// const btn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button-modern')
-// if (btn) {
-// btn.click()
-// }
-// const ad = [...document.querySelectorAll('.ad-showing')][0];
-// if (ad) {
-// document.querySelector('video').currentTime = 9999999999;
-// }
-// }, true);
-
-
-// this newer version is from
-// https://greasyfork.org/en/scripts/553239-auto-skip-youtube-ads/
-
-function skipAd() {
- if (checkIsYouTubeShorts()) return
-
- // This element appears when a video ad appears.
- const adShowing = document.querySelector('.ad-showing')
-
- // Timed pie countdown ad.
- const pieCountdown = document.querySelector('.ytp-ad-timed-pie-countdown-container')
-
- // Survey questions in video player.
- const surveyQuestions = document.querySelector('.ytp-ad-survey-questions')
-
- if (adShowing === null && pieCountdown === null && surveyQuestions === null) return
-
- const moviePlayerEl = document.querySelector('#movie_player')
- let playerEl
- let player
-
- if (isYouTubeMobile || isYouTubeMusic) {
- playerEl = moviePlayerEl
- player = playerEl
- } else {
- playerEl = document.querySelector('#ytd-player')
- player = playerEl && playerEl.getPlayer()
- }
-
- if (playerEl === null || player === null) {
- console.log({
- message: 'Player not found',
- timeStamp: getCurrentTimeString()
- })
- return
- }
-
- // ad.classList.remove('ad-showing')
-
- let adVideo = null
-
- if (pieCountdown === null && surveyQuestions === null) {
- adVideo = document.querySelector(
- '#ytd-player video.html5-main-video, #song-video video.html5-main-video'
- )
-
- console.table({
- message: 'Ad video',
- video: adVideo !== null,
- src: adVideo?.src,
- paused: adVideo?.paused,
- currentTime: adVideo?.currentTime,
- duration: adVideo?.duration,
- timeStamp: getCurrentTimeString()
- })
-
- if (adVideo !== null) {
- adVideo.muted = true
- }
- if (adVideo === null || !adVideo.src || adVideo.paused || isNaN(adVideo.duration)) {
- return
- }
-
- console.log({
- message: 'Ad video has finished loading',
- timeStamp: getCurrentTimeString()
- })
- }
-
- if (isYouTubeMusic && adVideo !== null) {
- adVideo.currentTime = adVideo.duration
-
- console.table({
- message: 'Ad skipped',
- timeStamp: getCurrentTimeString(),
- adShowing: adShowing !== null,
- pieCountdown: pieCountdown !== null,
- surveyQuestions: surveyQuestions !== null
- })
- } else {
- const videoData = player.getVideoData()
- const videoId = videoData.video_id
- const start = Math.floor(player.getCurrentTime())
-
- if (moviePlayerEl !== null && moviePlayerEl.isSubtitlesOn()) {
- window.setTimeout(moviePlayerEl.toggleSubtitlesOn, 1000)
- }
-
- if ('loadVideoWithPlayerVars' in playerEl) {
- playerEl.loadVideoWithPlayerVars({ videoId, start })
- } else {
- playerEl.loadVideoByPlayerVars({ videoId, start })
- }
-
- console.table({
- message: 'Ad skipped',
- videoId,
- start,
- title: videoData.title,
- timeStamp: getCurrentTimeString(),
- adShowing: adShowing !== null,
- pieCountdown: pieCountdown !== null,
- surveyQuestions: surveyQuestions !== null
- })
+document.addEventListener('load', () => {
+ const btn = document.querySelector('.videoAdUiSkipButton,.ytp-ad-skip-button-modern')
+ if (btn) {
+ btn.click()
}
-}
-
-function checkIsYouTubeShorts() {
- return location.pathname.startsWith('/shorts/')
-}
-
-function getCurrentTimeString() {
- return new Date().toTimeString().split(' ', 1)[0]
-}
-
-function addCss() {
- const adsSelectors = [
- // Ad banner in the upper right corner, above the video playlist.
- '#player-ads',
- '#panels > ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-ads"]',
-
- // Masthead ad on home page.
- '#masthead-ad',
-
- // Sponsored ad video items on home page.
- // 'ytd-ad-slot-renderer',
-
- // '.ytp-suggested-action',
- '.yt-mealbar-promo-renderer',
-
- // Featured product ad banner at the bottom left of the video.
- '.ytp-featured-product',
-
- // Products shelf ad banner below the video description.
- 'ytd-merch-shelf-renderer',
-
- // YouTube Music Premium trial promotion dialog, bottom left corner.
- 'ytmusic-mealbar-promo-renderer',
-
- // YouTube Music Premium trial promotion banner on home page.
- 'ytmusic-statement-banner-renderer'
- ]
- const adsSelector = adsSelectors.join(',')
- const css = `${adsSelector} { display: none !important; }`
- const style = document.createElement('style')
- style.textContent = css
- document.head.appendChild(style)
-}
-
-/**
- * Remove ad elements using JavaScript because these selectors require the use of the CSS
- * `:has` selector which is not supported in older browser versions.
- */
-function removeAdElements() {
- const adSelectors = [
- // Sponsored ad video items on home page.
- // ['ytd-rich-item-renderer', '.ytd-ad-slot-renderer'],
-
- // ['ytd-rich-section-renderer', '.ytd-statement-banner-renderer'],
-
- // Ad videos on YouTube Shorts.
- ['ytd-reel-video-renderer', '.ytd-ad-slot-renderer']
-
- // Ad blocker warning dialog.
- // ['tp-yt-paper-dialog', '#feedback.ytd-enforcement-message-view-model'],
-
- // Survey dialog on home page, located at bottom right.
- // ['tp-yt-paper-dialog', ':scope > ytd-checkbox-survey-renderer'],
-
- // Survey to rate suggested content, located at bottom right.
- // ['tp-yt-paper-dialog', ':scope > ytd-single-option-survey-renderer']
- ]
- for (const adSelector of adSelectors) {
- const adEl = document.querySelector(adSelector[0])
- if (adEl === null) continue
- const neededEl = adEl.querySelector(adSelector[1])
- if (neededEl === null) continue
- adEl.remove()
+ const ad = [...document.querySelectorAll('.ad-showing')][0];
+ if (ad) {
+ document.querySelector('video').currentTime = 9999999999;
}
-}
-
-const isYouTubeMobile = location.hostname === 'm.youtube.com'
-const isYouTubeDesktop = !isYouTubeMobile
+}, true);
-const isYouTubeMusic = location.hostname === 'music.youtube.com'
-const isYouTubeVideo = !isYouTubeMusic
-
-addCss()
-
-if (isYouTubeVideo) {
-window.setInterval(removeAdElements, 1000)
-removeAdElements()
-}
-
-window.setInterval(skipAd, 500)
-skipAd()
-
-
-// const observer = new MutationObserver(skipAd)
-// observer.observe(document.body, {
-// attributes: true,
-// attributeFilter: ['class'],
-// childList: true,
-// subtree: true
-// })
+// NOTE: the other version from
+// https://greasyfork.org/en/scripts/553239-auto-skip-youtube-ads/
+// doesn't work