PageSourceSearch

https://alanwatt.com/wp-content/plugins/paywall-for-woocommerce//assets/js/TIVWP.js?ver=5.0.1

js alanwatt.com collected 2026-10-10 00:52:47 UTC 2,515 bytes, 69 lines download raw bytes

1class TIVWP {
2
3    static #isDebug = false;
4
5    static set isDebug(yesNo) {
6        this.#isDebug = !!yesNo;
7    }
8
9    static #debugPrefix = "TIVWP";
10
11    static set debugPrefix(prefix) {
12        if (typeof prefix === "string") {
13            this.#debugPrefix = prefix;
14        }
15    }
16
17    static getCookie(name, default_value = "") {
18        const rawCookie = document.cookie
19            .split('; ')
20            .find(row => row.startsWith(`${name}=`));
21        return rawCookie ? rawCookie.split('=')[1] : default_value;
22    }
23
24    // Set a session cookie matching the PHP cookie attributes (path=/, SameSite=Strict,
25    // Secure on https). @since 5.0.0
26    static setCookie(name, value) {
27        const secure = location.protocol === "https:" ? "; Secure" : "";
28        document.cookie = `${name}=${value}; path=/; SameSite=Strict${secure}`;
29    }
30
31    // Expire a cookie now. @since 5.0.0
32    static unsetCookie(name) {
33        const secure = location.protocol === "https:" ? "; Secure" : "";
34        document.cookie = `${name}=; path=/; SameSite=Strict; max-age=0${secure}`;
35    }
36
37    static debug(sz) {
38        if (this.#isDebug) console.log(`${this.#debugPrefix}: ${sz}`);
39    }
40
41    static pageReload() {
42        TIVWP.debug('reloading');
43        const f = document.createElement("form");
44        f.method = "POST";
45        document.body.appendChild(f).submit();
46    }
47
48    static cacheBuster(cached, expected) {
49        TIVWP.debug(`expected=${expected}; cached=${cached}`);
50
51        // Reload only when the visitor actually carries a hash cookie that DIFFERS from the
52        // baked one. An absent cookie reads as "" and means "not a buyer" (no cart, no
53        // purchase) - there is nothing to upgrade, so we must NOT reload (this also removes
54        // the old cookies-disabled reload loop at the source). @since 5.0.0
55        if (expected !== "" && cached !== expected) {
56            TIVWP.pageReload();
57            return;
58        }
59
60        // No reload needed. If this load is the result of our own POST reload, a manual
61        // refresh (F5) would otherwise re-prompt to resend the POST; rewrite history to the
62        // current URL so the entry becomes a plain GET. Harmless (a same-URL no-op) after an
63        // ordinary GET, so we can run it unconditionally without a marker cookie. @since 5.0.0
64        if (window.history.replaceState) {
65            window.history.replaceState(null, "", window.location.href);
66        }
67    }
68}
69TIVWP.isDebug = !!TIVWP.getCookie("TIVWP_debug");

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.