annotate mandarake-direct-link.user.js @ 48:b60f0fd9c417

Update mandarake script - use modern javascript - vastly improve search
author nanaya <me@nanaya.pro>
date Wed, 11 Oct 2017 22:22:06 +0900
parents 32a213717e6a
children 2e1cae72a63e
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
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
4 // @version 1.3.0
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
35
32a213717e6a Update update url
nanaya <me@nanaya.pro>
parents: 33
diff changeset
10 // @downloadURL https://bitbucket.org/!api/2.0/snippets/nanayapro/TK64/tip/files/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
Edho Arief <me@myconan.net>
parents:
diff changeset
13 ;(function() {
33
Edho Arief <me@myconan.net>
parents: 20
diff changeset
14 "use strict";
16
Edho Arief <me@myconan.net>
parents:
diff changeset
15 $(".r18mark").remove()
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
16 var fixR18Link = function(_i, el) {
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
17 var url = `/order/detailPage/item?itemCode=${el.id}`
16
Edho Arief <me@myconan.net>
parents:
diff changeset
18
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
19 el.setAttribute("href", url)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
20 el.setAttribute("class", "")
33
Edho Arief <me@myconan.net>
parents: 20
diff changeset
21 }
16
Edho Arief <me@myconan.net>
parents:
diff changeset
22
48
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
23 $("[href^='#adult_confirm']").each(fixR18Link)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
24
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
25 var currentQuery = new URLSearchParams(location.search)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
26 var fixSearchLink = function(_i, el) {
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
27 var query = new URLSearchParams(el.search)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
28
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
29 for (let [key, value] of currentQuery) {
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
30 if (!query.has(key)) {
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
31 query.set(key, value)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
32 }
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
33 }
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
34
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
35 el.setAttribute("href", `/order/listPage/list?${query.toString()}`)
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 $("[href^='/order/listPage/list?']").each(fixSearchLink)
b60f0fd9c417 Update mandarake script
nanaya <me@nanaya.pro>
parents: 35
diff changeset
39 }).call();