annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
Edho Arief <me@myconan.net>
parents:
diff changeset
1 // ==UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
2 // @name Jiku-Chu direct link
Edho Arief <me@myconan.net>
parents:
diff changeset
3 // @namespace https://myconan.net
2
Edho Arief <me@myconan.net>
parents: 1
diff changeset
4 // @version 2.0
1
Edho Arief <me@myconan.net>
parents:
diff changeset
5 // @description Make proper link on Jiku-Chu pages
Edho Arief <me@myconan.net>
parents:
diff changeset
6 // @author nanaya
Edho Arief <me@myconan.net>
parents:
diff changeset
7 // @match http://www.jiku-chu.com/products/list.php?*
Edho Arief <me@myconan.net>
parents:
diff changeset
8 // @grant none
Edho Arief <me@myconan.net>
parents:
diff changeset
9 // ==/UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
10
2
Edho Arief <me@myconan.net>
parents: 1
diff changeset
11 ;(function() {
Edho Arief <me@myconan.net>
parents: 1
diff changeset
12 console.log("hi")
1
Edho Arief <me@myconan.net>
parents:
diff changeset
13 var
2
Edho Arief <me@myconan.net>
parents: 1
diff changeset
14 links = document.querySelectorAll(".title a, .photo a")
Edho Arief <me@myconan.net>
parents: 1
diff changeset
15 Array.prototype.forEach.call(links, function(el) {
Edho Arief <me@myconan.net>
parents: 1
diff changeset
16 var
Edho Arief <me@myconan.net>
parents: 1
diff changeset
17 productId = el.getAttribute("onclick").replace(/.*product_id=(\d+).*/, "$1"),
Edho Arief <me@myconan.net>
parents: 1
diff changeset
18 url = "/products/detail.php?product_id=" + productId
Edho Arief <me@myconan.net>
parents: 1
diff changeset
19 el.setAttribute("href", url)
Edho Arief <me@myconan.net>
parents: 1
diff changeset
20 el.setAttribute("onclick", "")
Edho Arief <me@myconan.net>
parents: 1
diff changeset
21 })
Edho Arief <me@myconan.net>
parents: 1
diff changeset
22 }).call();