annotate surugaya-always-consent.user.js @ 117:d9dc190bccaf

Undo combining fixes into single script per site
author nanaya <me@nanaya.net>
date Sun, 15 Jan 2023 23:49:35 +0900
parents 0e108a9dc6d7
children 8de2d53a4cb1
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==
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
2 // @name suruga-ya always consent
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
3 // @namespace https://nanaya.net
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
4 // @version 2.0.2
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
5 // @description always inject adult consent cookie
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
6 // @author nanaya
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
7 // @match https://www.suruga-ya.jp/*
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
8 // @grant none
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
9 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/surugaya-always-consent.user.js
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 }