annotate mandarake-direct-link.user.js @ 102:3fded109e23a

Also run on own node
author nanaya <me@nanaya.net>
date Sat, 24 Dec 2022 21:33:30 +0900
parents 9c8cde985caf
children b2d0b37f945f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
Edho Arief <me@myconan.net>
parents:
diff changeset
1 // ==UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
2 // @name mandarake direct link
Edho Arief <me@myconan.net>
parents:
diff changeset
3 // @namespace https://myconan.net
82
86da34e62d29 Update url
nanaya <me@nanaya.pro>
parents: 77
diff changeset
4 // @version 1.3.6
16
Edho Arief <me@myconan.net>
parents:
diff changeset
5 // @description Make proper link on mandarake pages
Edho Arief <me@myconan.net>
parents:
diff changeset
6 // @author nanaya
Edho Arief <me@myconan.net>
parents:
diff changeset
7 // @match https://order.mandarake.co.jp/*
18
Edho Arief <me@myconan.net>
parents: 17
diff changeset
8 // @match http://order.mandarake.co.jp/*
16
Edho Arief <me@myconan.net>
parents:
diff changeset
9 // @grant none
82
86da34e62d29 Update url
nanaya <me@nanaya.pro>
parents: 77
diff changeset
10 // @downloadURL https://hg.myconan.net/ec-userscripts/raw-file/tip/mandarake-direct-link.user.js
16
Edho Arief <me@myconan.net>
parents:
diff changeset
11 // ==/UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
12
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
13 /* global $ */
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
14 ;(function () {
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
15 'use strict'
51
f0d5a5d80bfd Remove extra element
nanaya <me@nanaya.pro>
parents: 49
diff changeset
16
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
17 $('.r18mark').remove()
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
18 $(".r18item ~ a[href^='#adult_confirm']").remove()
51
f0d5a5d80bfd Remove extra element
nanaya <me@nanaya.pro>
parents: 49
diff changeset
19
85
9c8cde985caf Update standard and fix
nanaya <me@nanaya.pro>
parents: 82
diff changeset
20 const fixR18Link = function (_i, el) {
9c8cde985caf Update standard and fix
nanaya <me@nanaya.pro>
parents: 82
diff changeset
21 const url = `/order/detailPage/item?itemCode=${el.id}`
16
Edho Arief <me@myconan.net>
parents:
diff changeset
22
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
23 el.setAttribute('href', url)
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
24 el.setAttribute('class', '')
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
25 }
16
Edho Arief <me@myconan.net>
parents:
diff changeset
26
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
27 $("[href^='#adult_confirm']").each(fixR18Link)
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
28
85
9c8cde985caf Update standard and fix
nanaya <me@nanaya.pro>
parents: 82
diff changeset
29 const currentQuery = new URLSearchParams(window.location.search)
9c8cde985caf Update standard and fix
nanaya <me@nanaya.pro>
parents: 82
diff changeset
30 const fixSearchLink = function (_i, el) {
9c8cde985caf Update standard and fix
nanaya <me@nanaya.pro>
parents: 82
diff changeset
31 const query = new URLSearchParams(el.search)
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
32
72
17c94a818088 Update lint
nanaya <me@nanaya.pro>
parents: 66
diff changeset
33 for (const [key, value] of currentQuery) {
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
34 if (!query.has(key)) {
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
35 query.set(key, value)
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
36 }
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
37 }
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
38
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
39 el.setAttribute('href', `/order/listPage/list?${query.toString()}`)
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
40 }
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
41
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
42 $("[href^='/order/listPage/list?']").each(fixSearchLink)
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
43 }).call()