-
Notifications
You must be signed in to change notification settings - Fork 0
/
cnm.r18.user.js
212 lines (196 loc) · 8.67 KB
/
cnm.r18.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
// ==UserScript==
// @name CNM.R18
// @name:zh-cn 刚满 18 岁
// @namespace https://github.com/Vinfall/UserScripts
// @version 2.14.0
// @author Vinfall
// @match https://*.itch.io/*
// @match https://*.reddit.com/over18?dest=*
// @match https://a.sofmap.com/adult_confirm.aspx?url=*
// @match https://a.sofmap.com/product_detail.aspx?sku=*
// @match https://appendingpulse.jp/dl/*
// @match https://booth.pm/*/items/*
// @match https://ec.toranoana.jp/tora_r/ec/item/*
// @match https://gamebanana.com/mods/*
// @match https://gamejolt.com/games/*/*
// @match https://gamejolt.com/games/*/*/followers
// @match https://www.hobicolle.com/
// @match https://jastusa.com/games/*/*
// @match https://jastusa.com/zh_Hans/games/*/*
// @match https://jastusa.com/zh_Hant/games/*/*
// @match https://moepedia.net/
// @match https://moepedia.net/*
// @match https://moepedia.net/game/*
// @match https://patch.moe/
// @match https://steamcommunity.com/app/*
// @match https://store.hikarifield.co.jp/downloads/*
// @match https://store.nintendo.com.hk/*
// @match https://www.animate-onlineshop.jp/pd/*
// @match https://www.animate-onlineshop.jp/pn/*
// @match https://www.animategames.jp/home/age?redirect=*
// @match https://www.digiket.com/work/show/_data/ID=*
// @match https://www.dlsite.com/*-touch/
// @match https://www.dlsite.com/*-touch/*
// @match https://www.dlsite.com/*/work/=/product_id/*
// @match https://www.dmm.co.jp/*/age_check/=/?rurl=*
// @match https://www.getchu.com/php/attestation.html?aurl=*
// @match https://www.johren.games/?backUrl=*
// @match https://www.melonbooks.co.jp/detail/detail.php?product_id=*
// @match https://www.nijiyome.jp/
// @match https://www.nijiyome.jp/*
// @match https://www.patreon.com/*
// @match https://www.ptt.cc/ask/over18?from=*
// @match https://www.will-order.com/age.php?rurl=*
// @exclude-match https://download.patch.moe/*
// @exclude-match https://store.nintendo.com.hk/checkout/*
// @exclude-match https://www.animate-onlineshop.jp/mypage/*
// @exclude-match https://www.melonbooks.co.jp/detail/detail.php?*adult_view=1
// @exclude-match https://www.patreon.com/create
// @exclude-match https://www.patreon.com/login
// @grant none
// @run-at document-start
// @license CC0 1.0 Universal (Public Domain)
// @icon data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🔞</text></svg>
// @description Certainly Not Minor, aka. CNM.R18
// @description:zh-cn 因为我刚满 18 岁~
// ==/UserScript==
// Buttons
function verifyButton() {
// Define rules
// prettier-ignore
const config = {
'a.sofmap.com': '.blue.button',
'animate-onlineshop.jp': 'dynamicSelector', // special case
'animategames.jp': '.btn-blr18.btn',
'appendingpulse.jp': '#in', // old releases
// new releases
// '.btn-danger.btn', '#fbi-warning > .modal-dialog > .modal-content > .modal-footer > .btn-primary.btn',
'booth.pm': '.js-approve-adult > .adult-check-nav',
'digiket.com': '.btn-lg.btn-info.btn',
'dlsite.com': 'dynamicSelector', // special case
'dmm.co.jp': '.css-w5doa7.fill.large.turtle-Button.turtle-component > [href]',
'gamebanana.com': '.ShowNsfwContentButton',
'gamejolt.com': '.link-muted > span', // this mutes until I exit
// 'gamejolt.com': '.-block.-outline.-primary.button', // this only works for once
'getchu.com': '[href^="https://www.getchu.com/soft.phtml"]',
// 'gog.com': '.age-gate__button.button--big.button', // not working
'hobicolle.com': '.close_modal',
'itch.io': '.buttons > .button',
'jastusa.com': '.content-gate__footer > button.is-primary.button',
'johren.games': '.link_enter.mainbtn-primary-lv1',
'moepedia.net': '.age-button_yes',
'nijiyome.jp': '.btn-approval.type_01',
'nintendo.com.hk': 'button#eco-product-confirmation-hide.action-primary',
'patch.moe': 'a.css-button-rounded--red:nth-of-type(1)',
'patreon.com': 'button[data-tag="age-verification-button-yes"]',
// 'ptt.cc': 'button.btm-big[name="yes"][value="yes"]', // not working
'reddit.com': 'button.c-btn-primary.c-btn:nth-of-type(2)',
'steamcommunity.com': 'button.btn_medium.btn_blue_steamui > span',
'store.hikarifield.co.jp': '.mt-3.btn-info.btn',
'toranoana.jp': '#js-en-confirm-adult > .c-modal_content_body > .text-center.c-modal_content_inner > .mt-4.ui-confirm-adult-btn-wrapper > .ui-confirm-adult-btn-primary.c-btn-black.c-btn.js-ui-modal-close.js-btn-primary',
'will-order.com': '[src="/images/age/yes_male.gif"]'
};
// These sites require verification every time
const noFlagSites = [
'appendingpulse.jp',
'touch', // DLsite mobile
];
function getSelectorForCurrentSite() {
const hostname = window.location.hostname;
const href = window.location.href;
for (const key in config) {
if (hostname.includes(key)) {
// Special handling for DLsite
if (key === 'dlsite.com') {
// Mobile
if (href.includes('touch')) {
return 'div.c-modal__button:nth-of-type(1)';
}
// PC
else {
const pathname = window.location.pathname;
return `[href="${pathname}"]`;
}
}
if (key === 'animate-onlineshop.jp') {
const pathname = window.location.pathname;
return `[href^="${pathname}"]`;
}
return config[key];
}
}
return null;
}
function autoConfirmAge() {
const hostname = window.location.hostname;
const href = window.location.href;
const sessionKey = `ageConfirmed-${hostname}`;
// Check if we've run on this site in this session
if (sessionStorage.getItem(sessionKey)) {
return;
}
const selector = getSelectorForCurrentSite();
if (!selector) {
console.warn('No matching rule found.');
return;
}
// Search for age verify button
const ageVerifyButton = document.querySelector(selector);
if (ageVerifyButton) {
ageVerifyButton.click();
// Skip flag on noFlagSites
if (noFlagSites.some((uri) => href.includes(uri))) {
return;
}
// Store a click flag in sessionStorage
sessionStorage.setItem(sessionKey, 'true');
return;
} else {
// If not found, try again later
setTimeout(autoConfirmAge, 800);
}
}
window.addEventListener('load', function () {
setTimeout(autoConfirmAge, 800);
});
}
// NSFW params
function verifyParam() {
// Define rules
const siteParams = {
'a.softmap.com': 'aac=on',
'melonbooks.co.jp': 'adult_view=1',
// Getchu not working even w/ url redirect, use verifyButton instead
// 'getchu.com': 'gc=gc',
};
const currentHost = window.location.host;
let currentUrl = window.location.href;
// Check existing params
for (const [site, paramToAdd] of Object.entries(siteParams)) {
if (currentHost.endsWith(site)) {
const sessionKey = `paramAdded-${currentHost}`;
if (sessionStorage.getItem(sessionKey)) {
continue;
}
// Check if the param already exists
if (!currentUrl.includes(paramToAdd)) {
let newUrl;
if (currentUrl.includes('?')) {
// host.tld?param=1
newUrl = currentUrl + '&' + paramToAdd;
} else {
// host.tld (aka. no param)
newUrl = currentUrl + '?' + paramToAdd;
}
window.location.href = newUrl;
sessionStorage.setItem(sessionKey, 'true');
return;
}
}
}
}
(function () {
'use strict';
verifyParam();
verifyButton();
})();