Greasy Fork

Greasy Fork is available in English.

Filmweb.pl - Disables auto-reload and ads

Adds ?audit=true to the URL to remove ads and prevent the page from auto-reload

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           Filmweb.pl - Disables auto-reload and ads
// @name:pl        Filmweb.pl - Brak Automatycznego odświeżania i reklam
// @description    Adds ?audit=true to the URL to remove ads and prevent the page from auto-reload
// @description:pl Dodaje ?audit=true do url, który zapobiega auto odświeżaniu strony i usuwa reklamy
// @version        1.0.0
// @author         Pabli
// @namespace      http://greasyfork.icu/users/124677-pabli
// @license        MIT
// @match          https://www.filmweb.pl/*
// @match          https://www.google.com/search*
// @match          https://duckduckgo.com/*
// @icon           https://www.google.com/s2/favicons?sz=64&domain=filmweb.pl
// @run-at         document-start
// @grant          GM_setValue
// @grant          GM_getValue
// @grant          GM_registerMenuCommand
// @grant          GM_unregisterMenuCommand
// ==/UserScript==
(async () => {
'use strict';

let settings = {
	cleanUrl: {
		value: await GM_getValue('cleanUrl', false),
		label: 'Usuń ?audit=true z URL po załadowaniu strony',
	}
};
let menuCommands = {};
async function updateMenu() {
	Object.keys(menuCommands).forEach(key => GM_unregisterMenuCommand(menuCommands[key]));
	Object.entries(settings).forEach(([key, config]) => {
		menuCommands[key] = GM_registerMenuCommand(
			`${config.value ? '☑' : '☐'} ${config.label}`,
			async () => {
				settings[key].value = !settings[key].value;
				await GM_setValue(key, settings[key].value);
				updateMenu();
			}
		);
	});
}
updateMenu();

Object.defineProperty(document, 'hidden', { value: false, writable: false });
Object.defineProperty(document, 'visibilityState', { value: 'visible', writable: false });

const url = new URL(window.location.href);

if (window.location.hostname === 'www.filmweb.pl') {
	if (!url.searchParams.has('audit')) {
		document.addEventListener('DOMContentLoaded', () => {
			url.searchParams.append('audit', 'true');
			window.location.href = url;
		});
	} else if (settings.cleanUrl.value) {
		setTimeout(() => {
			url.searchParams.delete('audit')
			window.history.replaceState({}, '', url);
		}, 3000);
	}
}

function auditParam(e) {
	const link = e.target;
	if (link.tagName === 'A' && link.hostname === 'www.filmweb.pl') {
		if (!link.dataset.audit) {
			const url = new URL(link.href);
			url.searchParams.append('audit', 'true');
			link.href = url.toString();
			link.dataset.audit = true;
		}
	}
}
document.addEventListener('mouseover', auditParam);
document.addEventListener('focusin', auditParam);

})();