PluginProbe
Age Gate / 3.7.3
Age Gate v3.7.3
3.7.3 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 All 113 releases
age-gate / src / Resources / assets / js / public / toolbar.js

toolbar.js in Age Gate 3.7.3, at src/Resources/assets/js/public/toolbar.js

54 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import Cookies from "js-cookie";
2 import { on } from '../admin/utility/on';
3
4 window.addEventListener('DOMContentLoaded', () => {
5
6 on('#wp-admin-bar-age-gate-toggle', 'click', '.ab-item', (e) => {
7 e.preventDefault();
8
9 const params = new URLSearchParams(e.target.href);
10 const ls = params.get("ls"); // is the string "Jonathan"
11
12 const { ag_cookie_domain, ag_cookie_name } = window;
13
14 if (!ls) {
15
16 if (Cookies.get(ag_cookie_name)) {
17 const data = new FormData;
18 data.append('action', 'ag_clear_cookie');
19 Cookies.set(ag_cookie_name, 1, {
20 path: '/',
21 domain: ag_cookie_domain,
22 expires: -1,
23 secure: window.location.protocol.match(/https/) ? true : false,
24 sameSite: window.location.protocol.match(/https/) ? 'None' : false,
25 });
26 } else {
27 Cookies.set(ag_cookie_name, '99', {
28 path: '/',
29 domain: ag_cookie_domain,
30 secure: window.location.protocol.match(/https/) ? true : false,
31 sameSite: window.location.protocol.match(/https/) ? 'None' : false,
32
33 });
34 }
35 } else {
36 if (localStorage.getItem(ag_cookie_name)) {
37 localStorage.removeItem(ag_cookie_name);
38 } else {
39 const currentTime = new Date().getTime();
40 const expires = new Date(currentTime + (1 * 60 * 60 * 1000)).getTime();
41
42 const item = {
43 value: 99,
44 expires,
45 };
46
47 localStorage.setItem(ag_cookie_name, JSON.stringify(item));
48 }
49 }
50
51 window.location.reload();
52 });
53 });
54