16
|
1 // ==UserScript==
|
|
2 // @name mandarake direct link
|
109
|
3 // @namespace https://nanaya.net
|
104
|
4 // @version 2.0.1
|
16
|
5 // @description Make proper link on mandarake pages
|
|
6 // @author nanaya
|
|
7 // @match https://order.mandarake.co.jp/*
|
18
|
8 // @match http://order.mandarake.co.jp/*
|
16
|
9 // @grant none
|
103
|
10 // @run-at document-start
|
|
11 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/mandarake-direct-link.user.js
|
16
|
12 // ==/UserScript==
|
|
13
|
108
|
14 'use strict';
|
103
|
15
|
109
|
16 function directLink () {
|
|
17 const r18ConfirmLink = '#adult_confirm';
|
|
18 function fixR18Link (link) {
|
|
19 if (!(link instanceof window.HTMLAnchorElement) || link.getAttribute('href') !== r18ConfirmLink) return;
|
|
20
|
|
21 link.setAttribute('href', `/order/detailPage/item?itemCode=${link.id}`);
|
|
22 link.removeAttribute('class');
|
|
23 }
|
51
|
24
|
109
|
25 function removeR18Mark (node) {
|
|
26 if (node.classList.contains('r18mark')) {
|
|
27 node.remove();
|
|
28 return true;
|
|
29 }
|
51
|
30
|
109
|
31 for (const mark of node.querySelectorAll('.r18mark')) {
|
|
32 mark.remove();
|
|
33 }
|
66
|
34 }
|
16
|
35
|
109
|
36 function run (node) {
|
|
37 if (!(node instanceof window.HTMLElement)) return;
|
|
38 if (removeR18Mark(node)) return;
|
|
39
|
|
40 fixR18Link(node);
|
|
41 for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) {
|
|
42 fixR18Link(link);
|
|
43 }
|
103
|
44 }
|
109
|
45
|
|
46 function onMutate (mutations) {
|
|
47 for (const mutation of mutations) {
|
|
48 for (const node of mutation.addedNodes) {
|
|
49 run(node);
|
|
50 }
|
|
51 }
|
|
52 }
|
|
53
|
|
54 const observer = new window.MutationObserver(onMutate);
|
|
55 observer.observe(document, { childList: true, subtree: true });
|
|
56 run(document.body);
|
103
|
57 }
|
48
|
58
|
109
|
59 directLink();
|