annotate surugaya-always-consent.user.js @ 136:1e64e81370a3

Add nginx-https
author nanaya <me@nanaya.net>
date Tue, 27 Feb 2024 01:17:43 +0900
parents bb4795a52a46
children
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
134
bb4795a52a46 Update consent cookie
nanaya <me@nanaya.net>
parents: 118
diff changeset
4 // @version 2.0.3
118
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
134
bb4795a52a46 Update consent cookie
nanaya <me@nanaya.net>
parents: 118
diff changeset
14 const hasAdultCookie = document.cookie.split('; ').includes('safe_search_expired=3');
116
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));
134
bb4795a52a46 Update consent cookie
nanaya <me@nanaya.net>
parents: 118
diff changeset
18 const options = `expires=${d.toGMTString()};path=/`;
bb4795a52a46 Update consent cookie
nanaya <me@nanaya.net>
parents: 118
diff changeset
19 document.cookie = `safe_search_expired=3;${options};`;
bb4795a52a46 Update consent cookie
nanaya <me@nanaya.net>
parents: 118
diff changeset
20 document.cookie = `safe_search_option=3;${options};`;
116
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
21 window.location.reload();
0e108a9dc6d7 Split suruga-ya scripts
nanaya <me@nanaya.net>
parents:
diff changeset
22 }