| 
16
 | 
     1 // ==UserScript==
 | 
| 
 | 
     2 // @name         mandarake direct link
 | 
| 
 | 
     3 // @namespace    https://myconan.net
 | 
| 
82
 | 
     4 // @version      1.3.6
 | 
| 
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
 | 
| 
82
 | 
    10 // @downloadURL  https://hg.myconan.net/ec-userscripts/raw-file/tip/mandarake-direct-link.user.js
 | 
| 
16
 | 
    11 // ==/UserScript==
 | 
| 
 | 
    12 
 | 
| 
66
 | 
    13 /* global $ */
 | 
| 
 | 
    14 ;(function () {
 | 
| 
 | 
    15   'use strict'
 | 
| 
51
 | 
    16 
 | 
| 
66
 | 
    17   $('.r18mark').remove()
 | 
| 
 | 
    18   $(".r18item ~ a[href^='#adult_confirm']").remove()
 | 
| 
51
 | 
    19 
 | 
| 
85
 | 
    20   const fixR18Link = function (_i, el) {
 | 
| 
 | 
    21     const url = `/order/detailPage/item?itemCode=${el.id}`
 | 
| 
16
 | 
    22 
 | 
| 
66
 | 
    23     el.setAttribute('href', url)
 | 
| 
 | 
    24     el.setAttribute('class', '')
 | 
| 
 | 
    25   }
 | 
| 
16
 | 
    26 
 | 
| 
66
 | 
    27   $("[href^='#adult_confirm']").each(fixR18Link)
 | 
| 
48
 | 
    28 
 | 
| 
85
 | 
    29   const currentQuery = new URLSearchParams(window.location.search)
 | 
| 
 | 
    30   const fixSearchLink = function (_i, el) {
 | 
| 
 | 
    31     const query = new URLSearchParams(el.search)
 | 
| 
48
 | 
    32 
 | 
| 
72
 | 
    33     for (const [key, value] of currentQuery) {
 | 
| 
48
 | 
    34       if (!query.has(key)) {
 | 
| 
66
 | 
    35         query.set(key, value)
 | 
| 
48
 | 
    36       }
 | 
| 
 | 
    37     }
 | 
| 
 | 
    38 
 | 
| 
66
 | 
    39     el.setAttribute('href', `/order/listPage/list?${query.toString()}`)
 | 
| 
 | 
    40   }
 | 
| 
48
 | 
    41 
 | 
| 
66
 | 
    42   $("[href^='/order/listPage/list?']").each(fixSearchLink)
 | 
| 
 | 
    43 }).call()
 |