| 
16
 | 
     1 // ==UserScript==
 | 
| 
 | 
     2 // @name         mandarake direct link
 | 
| 
 | 
     3 // @namespace    https://myconan.net
 | 
| 
48
 | 
     4 // @version      1.3.0
 | 
| 
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
 | 
| 
35
 | 
    10 // @downloadURL  https://bitbucket.org/!api/2.0/snippets/nanayapro/TK64/tip/files/mandarake-direct-link.user.js
 | 
| 
16
 | 
    11 // ==/UserScript==
 | 
| 
 | 
    12 
 | 
| 
 | 
    13 ;(function() {
 | 
| 
33
 | 
    14   "use strict";
 | 
| 
16
 | 
    15   $(".r18mark").remove()
 | 
| 
48
 | 
    16   var fixR18Link = function(_i, el) {
 | 
| 
 | 
    17     var url = `/order/detailPage/item?itemCode=${el.id}`
 | 
| 
16
 | 
    18 
 | 
| 
48
 | 
    19     el.setAttribute("href", url)
 | 
| 
 | 
    20     el.setAttribute("class", "")
 | 
| 
33
 | 
    21   }
 | 
| 
16
 | 
    22 
 | 
| 
48
 | 
    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)
 | 
| 
 | 
    39 }).call();
 |