GOG Claim Helper

Add a convenient link to the Privacy & Subscriptions webpage directly from the Claim banner

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         GOG Claim Helper
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Add a convenient link to the Privacy & Subscriptions webpage directly from the Claim banner
// @author       You
// @match        https://www.gog.com/en
// @match        https://www.gog.com
// @icon         https://www.google.com/s2/favicons?sz=64&domain=greasyfork.org
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 1. if button with class giveaway-banner__button is found, add a second button to
    // https://www.gog.com/en/account/settings/subscriptions
    //
    let giveawayButton = document.getElementsByClassName("giveaway-banner__button");
    if (giveawayButton.length > 0) {
        // document.getElementsByClassName("giveaway-banner__footer")[0];
        let element = document.createElement("button");
        element.id = "SettingsSubscriptionsButtonLink";
        element.style = "border: 1px solid transparent; border-radius: 3px; box-shadow: var(--theme-button-shadow); min-height: 46px; color: var(--theme-button-primary-text); background: var(--theme-button-primary) padding-box,var(--theme-button-primary-border);border-top-color: var(--theme-button-primary-border-top);border-bottom-color: var(--theme-button-primary-border-bottom);flex-shrink: 0;position: relative;padding: 16px 0;cursor: pointer; padding: 5px 10px 5px 10px;";
        element.onclick= function(e) {
            e.preventDefault();
            window.open('https://www.gog.com/en/account/settings/subscriptions');
            e.stopImmediatePropagation();
        };
        // element.classList.add("giveaway-banner__button");
        element.innerHTML= '<span class="giveaway-banner__button-text">Privacy and subscriptions</span>';

        document.getElementsByClassName("giveaway-banner__footer")[0].append(element);
    }
    // 2 if giveaway-banner__success is found,
    // add a button to giveaway-banner__button -> https://www.gog.com/en/account/settings/subscriptions

    // https://www.gog.com/en/account/settings/subscriptions

    var container = document.documentElement || document.body;

    const observer = new MutationObserver(function(mutations_list) {
        mutations_list.forEach(function(mutation) {
            if(mutation.target.id == 'giveaway') {
            console.log('new mutation');
            console.log(mutation)
            console.log(typeof mutation.target)
                console.log('giveaway-banner__success has been added');
                let element = document.createElement("button");
                element.id = "SettingsSubscriptionsButton";
                element.style = "border: 1px solid transparent; border-radius: 3px; box-shadow: var(--theme-button-shadow); min-height: 46px; color: var(--theme-button-primary-text); background: var(--theme-button-primary) padding-box,var(--theme-button-primary-border);border-top-color: var(--theme-button-primary-border-top);border-bottom-color: var(--theme-button-primary-border-bottom);flex-shrink: 0;position: relative;padding: 16px 0;width: 100%;cursor: pointer;margin: 5px 0 5px 0 !important; padding: 5px 10px 5px 10px;";
                element.onclick= function(e) {
                    e.preventDefault();
                    window.open('https://www.gog.com/en/account/settings/subscriptions');
                    e.stopImmediatePropagation();
                };
                // element.classList.add("giveaway-banner__button");
                element.innerHTML= '<span>Privacy and subscriptions</span>';

                console.log('giveaway appended 1');
                if(!document.getElementById("SettingsSubscriptionsButton")) {
                    document.getElementsByClassName("giveaway-banner__success-inner")[0].append(element);
                    console.log('giveaway appended');
                }

                // observer.disconnect();
            }
        });
    });
    observer.observe(container, { subtree: true, attributes: true, childList: true, characterData: true });


})();