annotate surugaya-always-consent.user.js @ 132:8ccdc82249a2

[mandarake direct link] the attribute now set after element is added
author nanaya <me@nanaya.net>
date Sun, 07 Jan 2024 19:20:25 +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 }