view jiku-chu-direct-link.user.js @ 116:0e108a9dc6d7

Split suruga-ya scripts
author nanaya <me@nanaya.net>
date Sun, 15 Jan 2023 23:46:56 +0900
parents ef21ef445fc6
children d9dc190bccaf
line wrap: on
line source

// ==UserScript==
// @name         Jiku-Chu direct link
// @namespace    https://nanaya.net
// @version      2.5.6
// @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://hg.nanaya.net/ec-userscripts/raw-file/tip/jiku-chu-direct-link.user.js
// ==/UserScript==

'use strict';

function directLink () {
  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);
}

directLink();