Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name filmweb.pl - "Widziałem, brak oceny"
- // @description Przywraca przycisk "Widziałem, brak oceny"
- // @version 2025-10-12
- // @match https://www.filmweb.pl/*
- // @icon https://fwcdn.pl/prt/static/images/fw/icons2/fw-favicons.ico
- // @grant none
- // ==/UserScript==
- (async function () {
- "use strict";
- const getCookie = (name) => {
- var match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));
- if (match) {
- return match[2];
- }
- return null;
- };
- const waitForElement = (elementProvider) =>
- new Promise((resolve) => {
- if (elementProvider()) {
- return resolve(elementProvider());
- }
- const observer = new MutationObserver((_) => {
- if (elementProvider()) {
- observer.disconnect();
- resolve(elementProvider());
- }
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true,
- });
- });
- const ratingPanel = await waitForElement(() =>
- document.querySelector(".ratingPanel")
- );
- const ratingText =
- ratingPanel &&
- (await waitForElement(
- () =>
- document.evaluate(
- "//div[starts-with(text(),'Oceń')]",
- ratingPanel,
- null,
- XPathResult.FIRST_ORDERED_NODE_TYPE
- )?.singleNodeValue
- ));
- const xsrfToken = getCookie("XSRF-TOKEN");
- if (ratingText && xsrfToken) {
- ratingText.addEventListener("mouseover", () => {
- ratingText.innerText = "Widziałem, brak oceny";
- ratingText.style = "cursor: pointer;";
- });
- ratingText.addEventListener("mouseout", () => {
- ratingText.innerText = "Oceń";
- ratingText.style = "";
- });
- const handleSeenClick = ratingText.addEventListener("click", async () => {
- ratingText.style = "";
- ratingText.removeEventListener("click", handleSeenClick);
- await fetch("https://www.filmweb.pl/api/v1/vote", {
- headers: {
- "content-type": "application/json",
- "x-xsrf-token": xsrfToken,
- },
- body: JSON.stringify({
- entity: window.globals.page.entity.id,
- rate: 0,
- entityName: window.globals.page.entity.type,
- }),
- method: "POST",
- });
- await new Promise(resolve => setTimeout(resolve, 1000));
- window.location.reload();
- });
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment