Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Anti-Spoilers GTA VI - Protection Ultime V6
- // @namespace local.anti-spoilers-gta-vi
- // @version 6.0.0
- // @description Protection anti-spoilers GTA VI : YouTube, Shorts, réseaux sociaux et forums.
- // @match *://youtube.com/*
- // @match *://www.youtube.com/*
- // @match *://m.youtube.com/*
- // @match *://x.com/*
- // @match *://www.x.com/*
- // @match *://twitter.com/*
- // @match *://www.twitter.com/*
- // @match *://instagram.com/*
- // @match *://www.instagram.com/*
- // @match *://jeuxvideo.com/*
- // @match *://www.jeuxvideo.com/*
- // @match *://reddit.com/*
- // @match *://www.reddit.com/*
- // @match *://old.reddit.com/*
- // @match *://tiktok.com/*
- // @match *://www.tiktok.com/*
- // @match *://facebook.com/*
- // @match *://www.facebook.com/*
- // @match *://threads.net/*
- // @match *://www.threads.net/*
- // @run-at document-start
- // @grant none
- // ==/UserScript==
- (() => {
- 'use strict';
- // ============================================================
- // PARAMETRES
- // ============================================================
- const BLOQUER_GTA_SEUL = true;
- const BLOQUER_NOMS_SEULS = true;
- const BLOQUER_ROCKSTAR = true;
- const CACHER_SUGGESTIONS_YT = true;
- const MODE_IMAGES_AVEUGLE = false;
- // true : bloque les titres mentionnant GTA, même GTA V.
- // false : bloque uniquement les références spécifiques à GTA VI.
- const MOTS_SUPPLEMENTAIRES = [
- // 'mon mot-cle',
- ];
- const NOMS = [
- 'Lucia',
- 'Lucia Caminos',
- 'Jason',
- 'Jason Duval',
- 'Cal',
- 'Cal Hampton',
- 'Boobie',
- 'Boobie Ike',
- "Dre'Quan",
- "Dre'Quan Priest",
- 'Drequan',
- 'Raul',
- 'Raul Bautista',
- 'Brian',
- 'Brian Heder',
- 'Real Dimez',
- 'Bae-Luxe',
- 'Roxy',
- 'Lori',
- 'DWNPLY'
- ];
- // ============================================================
- // TERMES DE SPOILERS
- // ============================================================
- const TERMES_SPOIL = [
- 'mort', 'morte', 'morts', 'meurt', 'meurent',
- 'mourir', 'mourra', 'deces', 'decede', 'decedee',
- 'assassine', 'assassinee', 'tue', 'tuer', 'tuee',
- 'suicide', 'survit', 'survie', 'trahit',
- 'trahison', 'traitre', 'fin', 'final', 'finale',
- 'ending', 'endings', 'dies', 'die', 'dead',
- 'death', 'killed', 'murder', 'murdered',
- 'betrays', 'betrayal', 'traitor', 'survives',
- 'secret', 'plot twist', 'twist', 'revelation',
- 'reveal', 'spoiler', 'spoilers', 'spoil',
- 'leak', 'leaks', 'leaked', 'leaking',
- 'cutscene', 'cinematique', 'scene finale',
- 'post credits', 'post credit', 'apres generique',
- 'true ending', 'bad ending', 'good ending',
- 'last mission', 'mission finale',
- 'dernier chapitre', 'chapitre final',
- 'ending explained', 'ending breakdown',
- 'game over', 'hidden ending',
- 'secret ending', 'alternate ending',
- 'character death', 'death scene',
- 'killing scene', 'final boss',
- 'final mission', 'last chapter'
- ];
- // ============================================================
- // TERMES ET LIEUX GTA VI
- // ============================================================
- const MOTIFS_SPECIFIQUES = [
- // GTA VI
- /(?:^|[^a-z0-9])g[\s._\-·•]*t[\s._\-·•]*a[\s._\-·•]*(?:6|vi|six)(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])grand[\s._\-·•]*theft[\s._\-·•]*auto[\s._\-·•]*(?:6|vi|six)(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])gtavi(?:6)?(?=$|[^a-z0-9])/iu,
- // Lieux
- /(?:^|[^a-z0-9])vice[\s._\-·•]*city(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])leonida(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])port[\s._\-·•]*gellhorn(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])mount[\s._\-·•]*kalaga(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])grassrivers(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])ambrosia(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])hamlet(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])vice[\s._\-·•]*beach(?=$|[^a-z0-9])/iu
- ];
- // ============================================================
- // SELECTEURS
- // ============================================================
- const YOUTUBE_CARTES = [
- 'ytd-rich-item-renderer',
- 'ytd-rich-grid-media',
- 'ytd-rich-grid-slim-media',
- 'ytd-video-renderer',
- 'ytd-grid-video-renderer',
- 'ytd-compact-video-renderer',
- 'ytd-reel-item-renderer',
- 'ytd-reel-video-renderer',
- 'ytd-shorts-lockup-view-model',
- 'yt-shorts-lockup-view-model',
- 'ytm-shorts-lockup-view-model',
- 'ytm-shorts-lockup-view-model-v2',
- 'ytm-rich-item-renderer',
- 'ytm-video-with-context-renderer',
- 'yt-lockup-view-model',
- 'ytd-playlist-renderer',
- 'ytd-comment-thread-renderer',
- 'ytd-notification-renderer',
- 'ytd-watch-metadata',
- 'ytm-video-renderer'
- ].join(',');
- const SELECTEURS = {
- 'youtube.com': [
- YOUTUBE_CARTES,
- 'a[href*="/shorts/"]',
- 'a[href*="/watch?v="]',
- 'ytd-rich-section-renderer'
- ].join(','),
- 'x.com': [
- 'article[data-testid="tweet"]',
- '[data-testid="trend"]',
- '[data-testid="notification"]',
- '[role="article"]'
- ].join(','),
- 'instagram.com': [
- 'article',
- '[role="article"]',
- 'main a[href*="/p/"]',
- 'main a[href*="/reel/"]'
- ].join(','),
- 'jeuxvideo.com': [
- 'ul.tablesForum--listTopics > li:not(.dfp__atf):not(.message)',
- '.topic-list > li:not(.dfp__atf):not(.message)',
- '.topic-list-item',
- '.topic-list tr',
- 'a.tablesForum__cellSubject',
- '.tablesForum__subjectText',
- '.topic-subject',
- 'a.lien-jv.topic-title',
- 'a.topic-title',
- '.messageUser',
- '.bloc-message-forum',
- '.message-forum',
- '[class*="message-forum"]'
- ].join(','),
- 'reddit.com': [
- 'shreddit-post',
- '[data-testid="post-container"]',
- '.thing.link',
- 'article'
- ].join(','),
- 'tiktok.com': [
- '[data-e2e="recommend-list-item-container"]',
- '[data-e2e="user-post-item"]',
- '[data-e2e="comment-item"]'
- ].join(','),
- 'facebook.com': '[role="article"]',
- 'threads.net': '[role="article"]'
- };
- // ============================================================
- // IDENTIFICATION DU SITE
- // ============================================================
- const h = location.hostname.toLowerCase().replace(/^www\./, '');
- const site =
- h === 'm.youtube.com' ? 'youtube.com' :
- h === 'old.reddit.com' ? 'reddit.com' :
- h;
- const selector = SELECTEURS[site];
- if (!selector) return;
- // ============================================================
- // NORMALISATION
- // ============================================================
- function normaliser(v) {
- return String(v || '')
- .normalize('NFKD')
- .replace(/[\u0300-\u036f]/g, '')
- .replace(/[\u200B-\u200D\u2060\uFEFF]/g, '')
- .toLowerCase()
- .replace(/[@4]/g, 'a')
- .replace(/[0]/g, 'o')
- .replace(/[3]/g, 'e')
- .replace(/\b1(?=[a-z])/g, 'i');
- }
- function echapper(s) {
- return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
- }
- function borne(s) {
- return new RegExp(
- '(?:^|[^a-z0-9])' +
- echapper(s) +
- '(?=$|[^a-z0-9])',
- 'iu'
- );
- }
- function creerRegexNomFragmentable(nom) {
- const compact = normaliser(nom)
- .replace(/[^a-z0-9]/g, '');
- if (!compact) return null;
- const lettres = [...compact]
- .map(echapper)
- .join('[^a-z0-9]*');
- return new RegExp(
- '(?:^|[^a-z0-9])' +
- lettres +
- '(?=$|[^a-z0-9])',
- 'iu'
- );
- }
- const nomsRgx = NOMS.flatMap(n => [
- borne(normaliser(n)),
- creerRegexNomFragmentable(n)
- ]).filter(Boolean);
- const termesRgx = TERMES_SPOIL.map(
- n => borne(normaliser(n))
- );
- const motsRgx = MOTS_SUPPLEMENTAIRES
- .filter(Boolean)
- .map(n => creerRegexNomFragmentable(n))
- .filter(Boolean);
- // ============================================================
- // DETECTION GTA
- // ============================================================
- const motifsJeu = [
- /(?:^|[^a-z0-9])g[\s._\-·•]*t[\s._\-·•]*a(?:[\s._\-·•]*(?:6|vi|v[\s._\-·•]*i|six))?(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])grand[\s._\-·•]*theft[\s._\-·•]*auto(?:[\s._\-·•]*(?:6|vi|six))?(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])gtavi(?:6)?(?=$|[^a-z0-9])/iu,
- /(?:^|[^a-z0-9])rockstar[\s._\-·•]*games(?=$|[^a-z0-9])/iu
- ];
- // ============================================================
- // FONCTION DE DETECTION PRINCIPALE
- // ============================================================
- function interdit(texte) {
- const s = normaliser(texte);
- // Références GTA VI et lieux.
- if (MOTIFS_SPECIFIQUES.some(r => r.test(s))) {
- return true;
- }
- // Références GTA en général.
- if (
- BLOQUER_GTA_SEUL &&
- motifsJeu.slice(0, 2).some(r => r.test(s))
- ) {
- return true;
- }
- // Rockstar Games.
- if (BLOQUER_ROCKSTAR && motifsJeu[3].test(s)) {
- return true;
- }
- // Mots personnalisés.
- if (motsRgx.some(r => r.test(s))) {
- return true;
- }
- // Personnages, même fragmentés.
- if (
- BLOQUER_NOMS_SEULS &&
- nomsRgx.some(r => r.test(s))
- ) {
- return true;
- }
- // Personnage + terme de spoiler.
- if (
- nomsRgx.some(r => r.test(s)) &&
- termesRgx.some(r => r.test(s))
- ) {
- return true;
- }
- return false;
- }
- // ============================================================
- // CSS DE PROTECTION
- // ============================================================
- function installerCSS() {
- if (
- !document.documentElement ||
- document.getElementById('anti-gta6-v6-style')
- ) return;
- const style = document.createElement('style');
- style.id = 'anti-gta6-v6-style';
- const selectorCache = site === 'jeuxvideo.com'
- ? [
- 'ul.tablesForum--listTopics > li:not(.dfp__atf):not(.message)',
- '.topic-list > li:not(.dfp__atf):not(.message)',
- '.topic-list-item',
- '.topic-list tr',
- '.messageUser',
- '.bloc-message-forum',
- '.message-forum',
- '[class*="message-forum"]'
- ].join(',')
- : selector;
- const css = [
- // Masquage préventif.
- `:is(${selectorCache}):not([data-anti-gta6="autorise"]) {
- visibility: hidden !important;
- }`,
- // Suppression des contenus interdits.
- '[data-anti-gta6="masque"] { display: none !important; }',
- // Protection des lignes JVC.
- ...(site === 'jeuxvideo.com' ? [
- 'ul.tablesForum--listTopics > li:not([data-anti-gta6="autorise"]) .tablesForum__subjectText { visibility:hidden!important; }',
- 'ul.tablesForum--listTopics > li[data-anti-gta6="masque"] { display:none!important; }'
- ] : []),
- // Page individuelle interdite.
- 'html[data-anti-gta6-page="masque"] body { visibility:hidden!important; }'
- ];
- if (site === 'youtube.com' && CACHER_SUGGESTIONS_YT) {
- css.push(
- '.sbdd_b,.gstl_50,yt-searchbox-suggestions-container,ytSearchboxComponentSuggestionsContainer { display:none!important; }'
- );
- }
- if (MODE_IMAGES_AVEUGLE) {
- css.push(
- 'main img,main video,article img,article video,ytd-thumbnail img,yt-image img,[role="article"] img,[role="article"] video { visibility:hidden!important; }'
- );
- }
- style.textContent = css.join('\n');
- document.documentElement.appendChild(style);
- }
- // ============================================================
- // IDENTIFICATION DE LA CARTE COMPLETE
- // ============================================================
- function carteCible(element) {
- if (site === 'youtube.com') {
- const carte = element.closest(
- 'ytd-rich-item-renderer,' +
- 'ytd-rich-grid-media,' +
- 'ytd-rich-grid-slim-media,' +
- 'ytd-video-renderer,' +
- 'ytd-grid-video-renderer,' +
- 'ytd-reel-item-renderer,' +
- 'ytd-reel-video-renderer,' +
- 'ytd-shorts-lockup-view-model,' +
- 'yt-shorts-lockup-view-model,' +
- 'ytm-shorts-lockup-view-model,' +
- 'ytm-shorts-lockup-view-model-v2,' +
- 'ytm-rich-item-renderer,' +
- 'ytm-video-with-context-renderer,' +
- 'yt-lockup-view-model'
- );
- if (carte) return carte;
- // Recherche d'un conteneur parent pour les structures
- // YouTube qui changent régulièrement.
- let parent = element;
- for (let i = 0; i < 7 && parent; i++) {
- if (
- parent.matches &&
- parent.matches(
- 'ytd-item-section-renderer,' +
- 'ytd-rich-section-renderer,' +
- 'ytm-section-list-renderer'
- )
- ) break;
- if (
- parent.matches &&
- parent.matches('a[href*="/shorts/"]')
- ) {
- return parent.parentElement || parent;
- }
- parent = parent.parentElement;
- }
- }
- if (site === 'jeuxvideo.com') {
- const ligne = element.closest(
- 'ul.tablesForum--listTopics > li:not(.dfp__atf):not(.message),' +
- '.topic-list > li:not(.dfp__atf):not(.message),' +
- '.topic-list-item,.topic-list tr'
- );
- if (ligne) return ligne;
- const lien = element.closest(
- 'a.tablesForum__cellSubject,' +
- 'a.lien-jv.topic-title,' +
- 'a.topic-title'
- );
- if (lien) {
- let parent = lien.parentElement;
- for (let i = 0; i < 5 && parent; i++, parent = parent.parentElement) {
- if (parent.matches(
- 'li,tr,[role="row"],.topic-list-item,[class*="tablesForum__row"]'
- )) {
- return parent;
- }
- if (parent.matches('ul,table,main,body')) break;
- }
- return lien;
- }
- }
- if (site === 'instagram.com') {
- const parent = element.closest('article,[role="article"]');
- if (parent) return parent;
- }
- return element;
- }
- // ============================================================
- // EXTRACTION DU TEXTE
- // ============================================================
- function texteElement(el) {
- let t = el.textContent || '';
- const attributs = [
- 'title',
- 'aria-label',
- 'alt',
- 'data-title',
- 'data-tooltip',
- 'content'
- ];
- for (const elem of el.querySelectorAll(
- '[title],[aria-label],[alt],[data-title],[data-tooltip],[content],a[href]'
- )) {
- for (const a of attributs) {
- t += ' ' + (elem.getAttribute(a) || '');
- }
- if (elem.matches('a[href]')) {
- t += ' ' + (elem.getAttribute('href') || '').split('?')[0];
- }
- }
- return t;
- }
- // ============================================================
- // FILE D'ANALYSE
- // ============================================================
- const file = new Set();
- let enCours = false;
- function traiter() {
- enCours = false;
- for (const el of file) {
- if (!el.isConnected) continue;
- const bloque = interdit(texteElement(el));
- el.setAttribute(
- 'data-anti-gta6',
- bloque ? 'masque' : 'autorise'
- );
- }
- file.clear();
- verifierPage();
- }
- function ajouter(el) {
- if (!el || !el.isConnected || el.nodeType !== 1) return;
- const cible = carteCible(el);
- el.removeAttribute('data-anti-gta6');
- cible.removeAttribute('data-anti-gta6');
- file.add(el);
- file.add(cible);
- if (!enCours) {
- enCours = true;
- requestAnimationFrame(traiter);
- }
- }
- // ============================================================
- // SCANNER
- // ============================================================
- function scanner(node, profondeur = true) {
- const el = node?.nodeType === 1
- ? node
- : node?.parentElement;
- if (!el) return;
- if (el.matches(selector)) {
- ajouter(el);
- }
- const parent = el.closest(selector);
- if (parent) {
- ajouter(parent);
- }
- if (profondeur) {
- el.querySelectorAll(selector).forEach(ajouter);
- }
- }
- // ============================================================
- // PROTECTION DES PAGES INDIVIDUELLES
- // ============================================================
- function verifierPage() {
- if (!document.documentElement) return;
- let chemin = location.pathname;
- try {
- chemin = decodeURIComponent(chemin);
- } catch (_) {}
- const pageMedia =
- /\/(watch|shorts|reel|p|video|videos|forums)\b/i.test(chemin);
- const titre =
- document.title + ' ' +
- chemin + ' ' +
- (document.querySelector('meta[name="title"]')?.content || '');
- document.documentElement.setAttribute(
- 'data-anti-gta6-page',
- pageMedia && interdit(titre)
- ? 'masque'
- : 'autorise'
- );
- }
- // ============================================================
- // DEMARRAGE
- // ============================================================
- function lancer() {
- installerCSS();
- scanner(document.documentElement);
- verifierPage();
- const observer = new MutationObserver(changements => {
- for (const m of changements) {
- if (m.type === 'childList') {
- m.addedNodes.forEach(n => scanner(n));
- scanner(m.target, false);
- } else {
- scanner(m.target, false);
- }
- }
- verifierPage();
- });
- observer.observe(document.documentElement, {
- subtree: true,
- childList: true,
- characterData: true,
- attributes: true,
- attributeFilter: [
- 'title',
- 'alt',
- 'aria-label',
- 'data-title',
- 'data-tooltip',
- 'href'
- ]
- });
- window.addEventListener('popstate', () => {
- verifierPage();
- scanner(document.documentElement);
- });
- }
- // ============================================================
- // INITIALISATION
- // ============================================================
- installerCSS();
- if (document.readyState === 'loading') {
- document.addEventListener(
- 'DOMContentLoaded',
- lancer,
- { once: true }
- );
- } else {
- lancer();
- }
- })();
Add Comment
Please, Sign In to add comment