annotate surugaya-always-consent.user.js @ 127:a701294f38ff

More reliable state handling
author nanaya <me@nanaya.net>
date Sat, 21 Jan 2023 03:15:26 +0900
parents 8de2d53a4cb1
children bb4795a52a46
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
116
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
1 // ==UserScript==
118
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
2 // @name suruga-ya always consent
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
3 // @namespace https://nanaya.net
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
4 // @version 2.0.2
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
5 // @description always inject adult consent cookie
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
6 // @author nanaya
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
7 // @match https://www.suruga-ya.jp/*
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
8 // @grant none
8de2d53a4cb1 Fix metadata
nanaya <me@nanaya.net>
parents: 116
diff changeset
9 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/surugaya-always-consent.user.js
116
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
10 // ==/UserScript==
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
11
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
12 'use strict';
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
13
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
14 const hasAdultCookie = document.cookie.split('; ').includes('adult=1');
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
15 if (!hasAdultCookie) {
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
16 const d = new Date();
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
17 d.setTime(d.getTime() + (100 * 24 * 60 * 60 * 1000));
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
18 document.cookie = `adult=1; expires=${d.toGMTString()}; path=/`;
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
19 window.location.reload();
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
20 }