comparison 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
comparison
equal deleted inserted replaced
47:bc45afe111d8 48:b60f0fd9c417
1 // ==UserScript== 1 // ==UserScript==
2 // @name mandarake direct link 2 // @name mandarake direct link
3 // @namespace https://myconan.net 3 // @namespace https://myconan.net
4 // @version 1.2.2 4 // @version 1.3.0
5 // @description Make proper link on mandarake pages 5 // @description Make proper link on mandarake pages
6 // @author nanaya 6 // @author nanaya
7 // @match https://order.mandarake.co.jp/* 7 // @match https://order.mandarake.co.jp/*
8 // @match http://order.mandarake.co.jp/* 8 // @match http://order.mandarake.co.jp/*
9 // @grant none 9 // @grant none
11 // ==/UserScript== 11 // ==/UserScript==
12 12
13 ;(function() { 13 ;(function() {
14 "use strict"; 14 "use strict";
15 $(".r18mark").remove() 15 $(".r18mark").remove()
16 var fixLink = function(_i, el) { 16 var fixR18Link = function(_i, el) {
17 var $el = $(el) 17 var url = `/order/detailPage/item?itemCode=${el.id}`
18 var url = "/order/detailPage/item?itemCode=" + $el.attr("id") + "&ref=list"
19 18
20 $el.attr("href", url) 19 el.setAttribute("href", url)
21 $el.removeClass() 20 el.setAttribute("class", "")
22 } 21 }
23 22
24 $("[href^='#adult_confirm']").each(fixLink) 23 $("[href^='#adult_confirm']").each(fixR18Link)
24
25 var currentQuery = new URLSearchParams(location.search)
26 var fixSearchLink = function(_i, el) {
27 var query = new URLSearchParams(el.search)
28
29 for (let [key, value] of currentQuery) {
30 if (!query.has(key)) {
31 query.set(key, value)
32 }
33 }
34
35 el.setAttribute("href", `/order/listPage/list?${query.toString()}`)
36 }
37
38 $("[href^='/order/listPage/list?']").each(fixSearchLink)
25 }).call(); 39 }).call();