Mercurial > ec-userscripts
annotate mandarake-direct-link.user.js @ 136:1e64e81370a3
Add nginx-https
author | nanaya <me@nanaya.net> |
---|---|
date | Tue, 27 Feb 2024 01:17:43 +0900 |
parents | 59c8866710f8 |
children |
rev | line source |
---|---|
16 | 1 // ==UserScript== |
118 | 2 // @name mandarake direct link |
3 // @namespace https://nanaya.net | |
135
59c8866710f8
[mandarake-direct-link] skip redundant node type check
nanaya <me@nanaya.net>
parents:
133
diff
changeset
|
4 // @version 2.0.3 |
118 | 5 // @description Make proper link on mandarake pages |
6 // @author nanaya | |
7 // @match https://order.mandarake.co.jp/* | |
8 // @match http://order.mandarake.co.jp/* | |
9 // @grant none | |
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 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
16 const r18ConfirmLink = '#adult_confirm'; |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
17 function fixR18Link (link) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
18 if (!(link instanceof window.HTMLAnchorElement) || link.getAttribute('href') !== r18ConfirmLink) return; |
51 | 19 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
20 link.setAttribute('href', `/order/detailPage/item?itemCode=${link.id}`); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
21 link.removeAttribute('class'); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
22 } |
51 | 23 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
24 function removeR18Mark (node) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
25 if (node.classList.contains('r18mark')) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
26 node.remove(); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
27 return true; |
66 | 28 } |
16 | 29 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
30 for (const mark of node.querySelectorAll('.r18mark')) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
31 mark.remove(); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
32 } |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
33 } |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
34 |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
35 function run (node) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
36 if (!(node instanceof window.HTMLElement)) return; |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
37 if (removeR18Mark(node)) return; |
109 | 38 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
39 fixR18Link(node); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
40 for (const link of node.querySelectorAll(`a[href='${r18ConfirmLink}']`)) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
41 fixR18Link(link); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
42 } |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
43 } |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
44 |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
45 function onMutate (mutations) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
46 for (const mutation of mutations) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
47 for (const node of mutation.addedNodes) { |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
48 run(node); |
109 | 49 } |
132
8ccdc82249a2
[mandarake direct link] the attribute now set after element is added
nanaya <me@nanaya.net>
parents:
118
diff
changeset
|
50 |
135
59c8866710f8
[mandarake-direct-link] skip redundant node type check
nanaya <me@nanaya.net>
parents:
133
diff
changeset
|
51 run(mutation.target); |
103 | 52 } |
53 } | |
48 | 54 |
117
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
55 const observer = new window.MutationObserver(onMutate); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
56 observer.observe(document, { childList: true, subtree: true }); |
d9dc190bccaf
Undo combining fixes into single script per site
nanaya <me@nanaya.net>
parents:
109
diff
changeset
|
57 run(document.body); |