Skip to content

Instantly share code, notes, and snippets.

@lebrunthibault
Last active February 28, 2023 17:42
Show Gist options
  • Save lebrunthibault/a09b9344ddd86c764d383cdd1085b7c7 to your computer and use it in GitHub Desktop.
Save lebrunthibault/a09b9344ddd86c764d383cdd1085b7c7 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Hide links on lemonde.fr
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide links on lemonde.fr
// @author You
// @match https://www.lemonde.fr/*
// @require https://gist.githubusercontent.com/lebrunthibault/a09b9344ddd86c764d383cdd1085b7c7/raw/tampermonkey.js?cachebust=dkjflskjfldkf3
// @icon https://play-lh.googleusercontent.com/aN_UGrgEUuShQGFMU1Kuhwy2cCU6CL9spKqAyP4MREEPzJuqrxvKQGPqPAyrshjmZM0=s180-rw
// @grant none
// ==/UserScript==
(function() {
'use strict';
const selectorsToHide = [];
const hide = selector => selectorsToHide.push(selector);
const disableLink = selector => document.querySelectorAll(selector).forEach(el => el.outerHTML = "<span>" + el.innerHTML + "</span>")
function hideLinks() {
hide(".left") // consultez le journal
hide(".Header__offer") // offrez le monde
hide("nav") // navbar
hide(".fw_most_read_recommendations") // les plus lus
hide(".paywall") // dans la même rubrique (en bas)
hide(".article__media") // photos
hide("#playerv5_box") // videos
hide(".podcast-area") // lien vers podcasts
//hide(".multimedia-embed") // images mais cache les graphiques aussi
hide(".services") // services : pubs en bas
hide("footer") // footer
document.querySelector(".right").style.position = "static" // login not sticky
document.querySelector(".center").style.position = "static" // logo not sticky
if (window.location.pathname === "/") { // homepage
hide("#en-continu") // fil "en continu" en haut
hide(".area--section") // blocs d'articles : les plus lus, opinion ..
hide(".article--featured") // blocs d'articles feature
hide(".zone--banniere") // bannier blanche vide en bas
hide(".article--river") // restrict articles home
} else {
hide(".meta__social") // liens de partage
hide(".catcher") // liens interparagraphes
disableLink(".zone--article a") // liens dans l'article
hide(".services-inread") // privilèges abonné : abonnez vous à la newsletter éco ..
hide(".insert") // bloc Edition du jour
hide(".article__reactions") // commentez
hide(".zone--article span:first-child") // Offrir le monde (et nom auteur)
hide("#d_ncov_approfondir") // pour approfondir
}
}
hideLinks()
hideSelectors(selectorsToHide);
})();
// ==UserScript==
// @namespace http://tampermonkey.net/
// @name Hide links lequipe.fr
// @version 0.1
// @description Hide links lequipe.fr
// @author You
// @match https://www.lequipe.fr/*
// @require https://gist.githubusercontent.com/lebrunthibault/a09b9344ddd86c764d383cdd1085b7c7/raw/tampermonkey.js?cachebust=dkjflskjfldkf3
// @icon chrome://favicon/http://www.lequipe.fr
// @grant none
// ==/UserScript==
(function() {
'use strict';
hideSelectors([
".Sidebar", // side bar (left) home
".TabBar", // side bar
".MainNav__items", // sports navbar
".ColLinkBlock", // bloc services home
".ChannelPlayer", // player video
"#playerv5_box", // player video
".Chrono", // chrono
".PaperEditionCol", // Edition papier
".Games", // bloc jeux et concours home
".CarouselWidget", // retrouvez les éditions
"#comments", // commentaires
".Article__paywall", // abonnez vous pour lire la suite
"footer",
".Home__widget:nth-child(n+6)"
])
for (const widget of [...document.querySelectorAll(".Home__widget")].slice(0, 15)) {
widget.classList.add("show")
}
})();
function hideSelectors(selectors, remove=false) {
// hide on page load
for (const selector of selectors) {
for (const el of document.querySelectorAll(selector)) {
if (remove) {
el.style.display="none"
} else {
el.style.visibility = "hidden"
}
}
}
// insert style sheet for future elements
let styles = null
if (remove) {
styles = selectors.join(", ") + ` { display: none !important; }`
} else {
styles = selectors.join(", ") + ` { visibility: hidden !important; }`
}
const styleSheet = document.createElement("style")
styleSheet.type = "text/css"
styleSheet.innerText = styles
console.log(`hid css selectors: ${selectors}`)
document.head.appendChild(styleSheet)
}
// ==UserScript==
// @name youtube.com
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.youtube.com/*
// @require https://gist.githubusercontent.com/lebrunthibault/a09b9344ddd86c764d383cdd1085b7c7/raw/tampermonkey.js
// @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
hideSelectors(["ytd-video-renderer.ytd-item-section-renderer:nth-child(n+6)"])
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment