16
|
1 // ==UserScript==
|
|
2 // @name mandarake direct link
|
|
3 // @namespace https://myconan.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
|
103
|
14 'use strict'
|
|
15
|
|
16 const r18ConfirmLink = '#adult_confirm'
|
|
17 function fixR18Link (link) {
|
|
18 if (!(link instanceof window.HTMLAnchorElement) || link.getAttribute('href') !== r18ConfirmLink) return
|
51
|
19
|
103
|
20 link.setAttribute('href', `/order/detailPage/item?itemCode=${link.id}`)
|
|
21 link.removeAttribute('class')
|
|
22 }
|
51
|
23
|
103
|
24 function removeR18Mark (node) {
|
|
25 if (node.classList.contains('r18mark')) {
|
|
26 node.remove()
|
|
27 return true
|
66
|
28 }
|
16
|
29
|
103
|
30 for (const mark of node.querySelectorAll('.r18mark')) {
|
|
31 mark.remove()
|
|
32 }
|
|
33 }
|
48
|
34
|
104
|
35 function run (node) {
|
|
36 if (!(node instanceof window.HTMLElement)) return
|
|
37 if (removeR18Mark(node)) return
|
|
38
|
|
39 fixR18Link(node)
|
|
40 for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) {
|
|
41 fixR18Link(link)
|
|
42 }
|
|
43 }
|
|
44
|
103
|
45 function onMutate (mutations) {
|
|
46 for (const mutation of mutations) {
|
|
47 for (const node of mutation.addedNodes) {
|
104
|
48 run(node)
|
48
|
49 }
|
103
|
50 }
|
|
51 }
|
48
|
52
|
103
|
53 const observer = new window.MutationObserver(onMutate)
|
|
54 observer.observe(document, { childList: true, subtree: true })
|
104
|
55 run(document.body)
|