view jiku-chu-direct-link.js @ 5:de6281203374

(none)
author Edho Arief <me@myconan.net>
date Sun, 03 May 2015 06:36:23 +0000
parents 59084566b064
children bd7febc9889b
line wrap: on
line source

// ==UserScript==
// @name         Jiku-Chu direct link
// @namespace    https://myconan.net
// @version      2.2
// @description  Make proper link on Jiku-Chu pages
// @author       nanaya
// @match        http://www.jiku-chu.com/products/list.php?*
// @grant        none
// ==/UserScript==

;(function() {
  Array.prototype.forEach.call(
    document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]"),
    function(el) {
      var
        productId = el.getAttribute("onclick").replace(/.*product_id=(\d+).*/, "$1"),
        url = "/products/detail.php?product_id=" + productId
      el.setAttribute("href", url)
      el.setAttribute("onclick", "")
    }
  )
}).call();