remove cnfans warning

removes the warning on cnfans

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

Advertisement:

// ==UserScript==
// @name        remove cnfans warning
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  removes the warning on cnfans
// @author       wumpus
// @match        *://*.cnfans.com/*
// @grant        none
// @license MIT
// ==/UserScript==
(function() {
    'use strict';

    function modifyUrl() {
        if (window.location.hostname.includes('cnfans.com')) {
            const currentUrl = new URL(window.location.href);
            const pageKey = `refAppended_${currentUrl.pathname}`;

            if (!sessionStorage.getItem(pageKey)) {
                if (currentUrl.searchParams.get('ref') !== '1003944') {
                    currentUrl.searchParams.set('ref', '1003944');
                    console.log('New URL:', currentUrl.href);
                    sessionStorage.setItem(pageKey, 'true');
                    window.location.href = currentUrl.href;
                }
            }
        }
    }

    function removeModal() {
        const modalElement = document.querySelector('div.custom-modal#keywords-modal');
        if (modalElement) {
            modalElement.remove();
            console.log('Removed custom modal: #keywords-modal');
        }
    }

    // Run URL modification immediately
    modifyUrl();

    // Run modal removal after the DOM is fully loaded
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', removeModal);
    } else {
        removeModal();
    }
})();