(Google Play Points) Check Availability

Checks if the weekly Google Play reward is ready to be claimed.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name            (Google Play Points) Check Availability
// @name:de         (Google Play Points) Verfügbarkeit Prüfen
// @description     Checks if the weekly Google Play reward is ready to be claimed.
// @description:de  Prüft, ob die wöchentliche Google Play Prämie zum Einlösen bereit ist.
// @version         0.0.1.6
// @author          Wack.3gp (https://greasyfork.org/users/4792)
// @copyright       2024+, Wack.3gp
// @namespace       https://greasyfork.org/users/4792
// @license         CC BY-NC-ND 4.0; http://creativecommons.org/licenses/by-nc-nd/4.0/
// @icon            https://www.gstatic.com/android/market_images/web/favicon_v3.ico
//
// @include         *
// @noframes
// @run-at          document-idle
//
// @grant           GM_notification
// @grant           GM_xmlhttpRequest
// @grant           GM_registerMenuCommand
// @grant           GM_setValue
// @grant           GM_getValue
//
// @supportURL      https://greasyfork.org/scripts/493895/feedback
// @compatible      Chrome tested with Tampermonkey
// @contributionURL https://www.paypal.com/donate/?hosted_button_id=BYW9D395KJWZ2
// @contributionAmount €1.00
// ==/UserScript==

(function() {
    'use strict';

    const _vault = "4792";
    const _isOriginal = GM_info.script.namespace.includes(_vault);
    const _originalURL = "https://greasyfork.org/scripts/493895";

    const perksUrl = "https://play.google.com/store/points/perks";

    const checkProtection = () => {
        if (!_isOriginal) {
            alert("Please install the Original Version");
            window.location.href = _originalURL;
            return false;
        }
        return true;
    };

    function runCheck() {
        if (!checkProtection()) return;

        const today = new Date().toDateString();

        if (GM_getValue("lastSuccessfulClaimCheck") === today) {
            return;
        }

        GM_xmlhttpRequest({
            method: "GET",
            url: perksUrl,
            anonymous: false, 
            onload: function(response) {
                let parser = new DOMParser();
                let doc = parser.parseFromString(response.responseText, "text/html");

                const buttons = Array.from(doc.querySelectorAll("button"));
                const claimButton = buttons.find(btn => 
                    btn.textContent.includes("Einlösen") || btn.textContent.includes("Claim")
                );

                if (claimButton) {
                    const isDisabled = claimButton.hasAttribute('disabled') || 
                                       claimButton.getAttribute('aria-disabled') === 'true' ||
                                       claimButton.classList.contains('disabled');

                    if (!isDisabled) {
                        GM_notification({
                            title: "Google Play Points",
                            text: "Your weekly reward is available! Click here to claim it.",
                            image: "https://www.gstatic.com/images/branding/product/2x/google_play_96dp.png",
                            onclick: function() {
                                window.open(perksUrl, "_blank");
                            }
                        });
                    }
                } else {
                    const html = response.responseText;
                    if (html.includes("Prämie") || html.includes("Gold") || html.includes("Reward")) {
                        GM_setValue("lastSuccessfulClaimCheck", today);
                    }
                }
            }
        });
    }

    let lastExecution = GM_getValue("lastCheckTimestamp", 0);
    let currentTime = Date.now();

    if (currentTime - lastExecution > 1000 * 60 * 60 * 24) {
        GM_setValue("lastCheckTimestamp", currentTime);
        runCheck();
    }

    GM_registerMenuCommand("⭐ Check Play Points", function() {
        runCheck();
    });

        GM_registerMenuCommand("☕ Buy Me a Coffee :)", function () {
alert("Hello, I'm " + GM_info.script.author + "\nand I wrote this script as a hobby.\nIf you find it useful, buy me a coffee :)");
    window.open(GM_info.script.header.match(/@contributionURL\s+(.+)/)[1], "_blank");
        });

    if (_isOriginal) {
        console.log(`%c ${GM_info.script.name} v${GM_info.script.version} %c (Verified Original)`, 
                    "background: #f44336; color: white; font-weight: bold; padding: 2px 5px;", "color: #f44336;");
    }

})();