view mandarake-direct-link.user.js @ 88:14eafa2920c8

Update dependencies
author nanaya <me@nanaya.pro>
date Sat, 04 Dec 2021 04:06:31 +0900
parents 9c8cde985caf
children b2d0b37f945f
line wrap: on
line source

// ==UserScript==
// @name         mandarake direct link
// @namespace    https://myconan.net
// @version      1.3.6
// @description  Make proper link on mandarake pages
// @author       nanaya
// @match        https://order.mandarake.co.jp/*
// @match        http://order.mandarake.co.jp/*
// @grant        none
// @downloadURL  https://hg.myconan.net/ec-userscripts/raw-file/tip/mandarake-direct-link.user.js
// ==/UserScript==

/* global $ */
;(function () {
  'use strict'

  $('.r18mark').remove()
  $(".r18item ~ a[href^='#adult_confirm']").remove()

  const fixR18Link = function (_i, el) {
    const url = `/order/detailPage/item?itemCode=${el.id}`

    el.setAttribute('href', url)
    el.setAttribute('class', '')
  }

  $("[href^='#adult_confirm']").each(fixR18Link)

  const currentQuery = new URLSearchParams(window.location.search)
  const fixSearchLink = function (_i, el) {
    const query = new URLSearchParams(el.search)

    for (const [key, value] of currentQuery) {
      if (!query.has(key)) {
        query.set(key, value)
      }
    }

    el.setAttribute('href', `/order/listPage/list?${query.toString()}`)
  }

  $("[href^='/order/listPage/list?']").each(fixSearchLink)
}).call()