Mercurial > ec-userscripts
diff 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 |
line wrap: on
line diff
--- a/mandarake-direct-link.user.js Thu Aug 24 20:57:01 2017 +0900 +++ b/mandarake-direct-link.user.js Wed Oct 11 22:22:06 2017 +0900 @@ -1,7 +1,7 @@ // ==UserScript== // @name mandarake direct link // @namespace https://myconan.net -// @version 1.2.2 +// @version 1.3.0 // @description Make proper link on mandarake pages // @author nanaya // @match https://order.mandarake.co.jp/* @@ -13,13 +13,27 @@ ;(function() { "use strict"; $(".r18mark").remove() - var fixLink = function(_i, el) { - var $el = $(el) - var url = "/order/detailPage/item?itemCode=" + $el.attr("id") + "&ref=list" + var fixR18Link = function(_i, el) { + var url = `/order/detailPage/item?itemCode=${el.id}` - $el.attr("href", url) - $el.removeClass() + el.setAttribute("href", url) + el.setAttribute("class", "") } - $("[href^='#adult_confirm']").each(fixLink) -}).call(); \ No newline at end of file + $("[href^='#adult_confirm']").each(fixR18Link) + + var currentQuery = new URLSearchParams(location.search) + var fixSearchLink = function(_i, el) { + var query = new URLSearchParams(el.search) + + for (let [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();