view jiku-chu-direct-link.js @ 2:ce30c81f3f0c

(none)
author Edho Arief <me@myconan.net>
date Sun, 03 May 2015 04:21:46 +0000
parents f0c125358b24
children 7687bbda0bb4
line wrap: on
line source

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

;(function() {
  console.log("hi")
  var
    links = document.querySelectorAll(".title a, .photo a")
  Array.prototype.forEach.call(links, 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();