view jiku-chu-direct-link.user.js @ 57:09f735548b2c

No more snippets
author nanaya <me@nanaya.pro>
date Fri, 20 Jul 2018 00:43:27 +0900
parents e8517cc75a74
children 960d452dea99
line wrap: on
line source

// ==UserScript==
// @name         Jiku-Chu direct link
// @namespace    https://myconan.net
// @version      2.5.2
// @description  Make proper link on Jiku-Chu pages
// @author       nanaya
// @match        http://www.jiku-chu.com/*
// @match        https://www.jiku-chu.com/*
// @grant        none
// @downloadURL  https://bitbucket.org/nanayapro/ec-userscripts/raw/tip/jiku-chu-direct-link.user.js
// ==/UserScript==

;(function () {
  'use strict';
  const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]");
  const removeOnClick = function (el) {
    const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1');
    const url = `/products/detail.php?product_id=${productId}`;

    el.setAttribute('href', url);
    el.setAttribute('onclick', '');
  };

  Array.prototype.forEach.call(links, removeOnClick);
}());