Skip to content

Instantly share code, notes, and snippets.

@eslin
Created April 7, 2025 20:11
Show Gist options
  • Save eslin/750dedea0b7cfd8e1cc14ed78e395176 to your computer and use it in GitHub Desktop.
Save eslin/750dedea0b7cfd8e1cc14ed78e395176 to your computer and use it in GitHub Desktop.
tampermonkey: SVT spoiler remover
// ==UserScript==
// @name SVT Spoiler remover
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove elements with class names starting with '_highlight_'
// @author You
// @match https://www.svtplay.se/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function removeSpecificNav() {
// Select the nav element with the specific class and aria-label
var targetElement = document.querySelector('nav[aria-label="Navigera mellan kapitel i videon."]');
if (targetElement) {
// Remove the element from the DOM
targetElement.parentNode.removeChild(targetElement);
console.log('Removed specific nav element:', targetElement);
} else {
console.log('Specific nav element not found.');
}
}
function removeHighlightElements() {
// Use a CSS attribute selector to find elements with class names starting with '_highlight_'
var elements = document.querySelectorAll('[class^="_highlight_"], [class*=" _highlight_"]');
elements.forEach(function(element) {
// Remove the element from the DOM
element.parentNode.removeChild(element);
console.log('Removed element:', element);
});
}
// Call the removal function initially
removeSpecificNav();
removeHighlightElements();
// Set up a MutationObserver to handle dynamically added elements
const observer = new MutationObserver(function(mutations) {
removeHighlightElements();
removeSpecificNav();
console.log('jajävlar');
});
// Configuration for the observer (which mutations to observe)
const config = { childList: true, subtree: true };
// Start observing the document body for added nodes
observer.observe(document.body, config);
})();
@eslin
Copy link
Author

eslin commented Apr 7, 2025

Removes events in the timeline of SVT streams, created to remove the spoilers of football games watched at a later time where SVT has added events like "penalty kick" mid game

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment