# HG changeset patch # User Edho Arief # Date 1430626906 0 # Node ID ce30c81f3f0caf5f733240d8403437469c24087a # Parent f0c125358b244f7feddf9c38e4e82e8b0e3a218b diff -r f0c125358b24 -r ce30c81f3f0c jiku-chu-direct-link.js --- a/jiku-chu-direct-link.js Sun May 03 04:04:42 2015 +0000 +++ b/jiku-chu-direct-link.js Sun May 03 04:21:46 2015 +0000 @@ -1,18 +1,22 @@ // ==UserScript== // @name Jiku-Chu direct link // @namespace https://myconan.net -// @version 1.0 +// @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== -$(".title a").each(function() { +;(function() { + console.log("hi") var - $el = $(this), - productId = $el.attr("onclick").replace(/.*product_id=(\d+).*/, "$1"), - url = "/products/detail.php?product_id=" + productId - $el.attr("href", url) - $el.attr("onclick", "") -}) \ No newline at end of file + 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(); \ No newline at end of file