Skip to content

Instantly share code, notes, and snippets.

@nielsAD
Last active November 4, 2023 09:12
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nielsAD/d04568f2f240a9f0b225897e318bb2a9 to your computer and use it in GitHub Desktop.
Save nielsAD/d04568f2f240a9f0b225897e318bb2a9 to your computer and use it in GitHub Desktop.
Greasemonkey user scripts
// ==UserScript==
// @description Decline NPR cookies
// @name choice.npr
// @namespace nielsAD
// @include *://choice.npr.org/*
// @version 1
// @grant none
// ==/UserScript==
const decline = document.getElementById("textLink");
if (decline) {
decline.click();
}
// ==UserScript==
// @description Accept kudtkoekiewet cookies
// @name kudtkoekiewet
// @namespace nielsAD
// @include *://kudtkoekiewet.nl/*
// @include *://cookies.dumpert.nl/*
// @include *://www.geenstijl.nl/*
// @version 1.0.1
// @grant none
// ==/UserScript==
const ja = document.getElementById("jakoekies");
if (ja) {
ja.click();
}
const btn = document.getElementsByClassName("approve-btn")[0]
if (btn) {
btn.click();
}
// ==UserScript==
// @description Hide Marktplaats ads
// @name marktplaats
// @namespace nielsAD
// @include *://www.marktplaats.nl/*
// @version 1.2.1
// @grant none
// @require https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js
// ==/UserScript==
const obs = new MutationObserver(function() {
$(".hz-Listings__admarktTitle").hide();
$(".hz-Listing .hz-Listing-seller-link").closest("li").hide();
$(".hz-Listing .hz-Listing-location:contains('Bezorgt in ')").closest("li").hide();
$(".hz-Listing .hz-Listing-location:contains('Heel Nederland')").closest("li").hide();
});
obs.observe(document.getElementById('__next'), { childList: true, subtree: true });
// ==UserScript==
// @description Hide NRC overlay
// @name nrc
// @namespace nielsAD
// @include *://www.nrc.nl/*
// @version 1
// @grant none
// @run-at document-idle
// ==/UserScript==
document.documentElement.classList.remove("dark-mode");
document.querySelectorAll("img.b-lazy").forEach(img => {
const src = img.dataset.src.split("|");
img.loading = "lazy"
img.src = src[src.length - 1];
img.style.maxWidth = "100%";
img.classList.remove("b-lazy");
});
document.querySelectorAll("div.b-lazy").forEach(div => {
const src = div.dataset.src.split("|");
const img = document.createElement('img');
img.loading = "lazy"
img.src = src[src.length - 1];
img.style.maxWidth = "100%";
div.classList.remove("b-lazy");
div.appendChild(img);
});
// ==UserScript==
// @description Accept persgroep cookies
// @name persgroep
// @namespace nielsAD
// @include *://cmp.nu.nl/*
// @include *://cmp.dpgmedia.nl/*
// @version 1.0.4
// @grant none
// @run-at document-idle
// ==/UserScript==
const obs = new MutationObserver(function() {
const agree = document.querySelector('#notice .pg-accept-button');
if (agree) {
agree.click();
}
});
obs.observe(document.body, { childList: true });
// ==UserScript==
// @description Accept privacy-center cookies
// @name privacy-center
// @namespace nielsAD
// @include *://www.dumpert.nl/*
// @version 1.0.1
// @grant none
// ==/UserScript==
const obs = new MutationObserver(function() {
const host = document.getElementById("didomi-host");
if (!host) return;
setTimeout(function(){
const agree = document.getElementById("didomi-notice-agree-button");
if (agree) {
agree.click();
}
}, 0);
});
obs.observe(document.body, { childList: true });
// ==UserScript==
// @description Disable Twitch automatically changing video quality when playing in background
// @name twitch.tv
// @namespace nielsAD
// @include *://*.twitch.tv/*
// @version 1.1.0
// @grant none
// ==/UserScript==
// Insert like this to work around greasemonkey jail
const fun = function() {
Object.defineProperty(document, 'hidden', {value: false, writable: false});
Object.defineProperty(document, 'visibilityState', {value: 'visible', writable: false});
Object.defineProperty(document, 'webkitVisibilityState', {value: 'visible', writable: false});
document.dispatchEvent(new Event('visibilitychange'));
};
const node = document.createElement('script');
node.type = "text/javascript";
node.textContent = '(' + fun.toString() + ')()';
document.body.appendChild(node);
setInterval(function(){
const bonus = document.getElementsByClassName("claimable-bonus__icon");
for (let b of bonus) {
b.click();
}
}, 5000);
// ==UserScript==
// @name youtube
// @namespace nielsAD
// @description YouTube theater mode
// @include *://*.youtube.com/*
// @version 1.2.1
// @grant none
// ==/UserScript==
const fun = function(ajaxOpen) {
// ==================================
// Disable "Are you still there?"
// ==================================
yt.util.activity.getTimeSinceActive = function() { return 0; };
// ================
// Theater mode
// ================
function theaterMode() {
const theater = (document.getElementsByClassName("ytp-size-button") || [])[0];
if (theater && theater.title.indexOf("heater") !== -1) {
theater.click();
}
const watch = document.getElementById("page");
if (watch && watch.classList.contains("watch")) {
watch.classList.remove("watch-non-stage-mode");
watch.classList.add("watch-stage-mode");
watch.classList.add("watch-wide");
}
}
window.addEventListener("yt-navigate-finish", theaterMode);
theaterMode();
// ===================
// Audio-only mode
// ===================
function audioMode() {
if (location.pathname == "/watch") {
let video = document.getElementsByTagName("video")[0];
let audioMode = localStorage.getItem("ytAudioMode") === "true";
addAudioModeToMenu(audioMode);
if (audioMode) {
setPoster(video, ["maxres", "hq", "sd"]);
XMLHttpRequest.prototype.open = function(method, url) {
let validStream = /^(?!.*live=1).+audio.+$/;
if (validStream.test(url) && ! video.src.includes("audio")) {
video.pause();
video.src = url.split("&range")[0];
video.play();
}
ajaxOpen.apply(this, arguments);
}
}
}
}
// Add audio mode to the settings menu
function addAudioModeToMenu(enabled) {
let panel = document.getElementsByClassName("ytp-panel-menu")[0];
if (!panel.innerHTML.includes("Audio Mode")) {
panel.innerHTML += `
<div class="ytp-menuitem"
aria-checked="${enabled}"
id="audio-mode">
<div class="ytp-menuitem-icon"></div>
<div class="ytp-menuitem-label">Audio Mode</div>
<div class="ytp-menuitem-content">
<div class="ytp-menuitem-toggle-checkbox">
</div>
</div>`;
// Toggle audio mode on or off
let audioToggle = document.getElementById("audio-mode");
audioToggle.onclick = function() {
let audioMode = localStorage.getItem("ytAudioMode") !== "true";
this.setAttribute("aria-checked", audioMode);
localStorage.setItem("ytAudioMode", audioMode);
location.reload();
}
}
}
function setPoster(video, fmts) {
let img = new Image();
let videoId = location.search.match(/v=(.+?)(&|$)/)[1];
img.src = `//i.ytimg.com/vi/${videoId}/${fmts.shift()}default.jpg`
img.onload = function() {
// A height 90 is YouTube"s not found image.
if (img.height <= 90) {
setPoster(video, fmts);
} else {
video.style.background = `url(${img.src}) no-repeat center`;
video.style.backgroundSize = "contain";
}
};
}
window.addEventListener("yt-navigate-finish", audioMode);
audioMode();
};
window.addEventListener("yt-navigate-finish", function() {
const node = document.createElement('script');
node.type = "text/javascript";
node.textContent = '(' + fun.toString() + ')(XMLHttpRequest.prototype.open)';
document.body.appendChild(node);
}, {once: true});
@flacito13
Copy link

dank je wel

@Wasmachineman-NL
Copy link

Bugreport: Marktplaats userscript werkt niet goed. Ze willen echt niet dat je die stomme advertenties filtert, want je krijgt deze fout als je naar de volgende pagina gaat: https://i.imgur.com/eXnYi87.png

En ook een feature request: kleinere advertenties, die gigantisch grote advertenties nemen heel mijn scherm in beslag. En als we toch bezig zijn: 100 advertenties per pagina optie, want die idioten hebben die optie weer verwijderd.

@nielsAD
Copy link
Author

nielsAD commented Jan 25, 2021

@Wasmachineman-NL Marktplaats script zou weer moeten werken! Voor een script met meer features zou je eens hier kunnen kijken.

@flacito13
Copy link

flacito13 commented Jan 25, 2021 via email

@Wasmachineman-NL
Copy link

@nielsAD wow dat script van Arnold werkt goed zeg :O eindelijk een manier om die debielen zoals Arpe Kampen met zijn 10000 verschillende accounts te filteren als ik iets van Asko zoek.

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