annotate jiku-chu-direct-link.user.js @ 101:e21710f5dd7b

Also run on its own node
author nanaya <me@nanaya.net>
date Sat, 24 Dec 2022 21:31:42 +0900
parents 86da34e62d29
children 2c4470b73ad9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
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
82
86da34e62d29 Update url
nanaya <me@nanaya.pro>
parents: 77
diff changeset
4 // @version 2.5.6
14
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/*
50
e8517cc75a74 Add https, update coding style
nanaya <me@nanaya.pro>
parents: 49
diff changeset
8 // @match https://www.jiku-chu.com/*
14
Edho Arief <me@myconan.net>
parents:
diff changeset
9 // @grant none
82
86da34e62d29 Update url
nanaya <me@nanaya.pro>
parents: 77
diff changeset
10 // @downloadURL https://hg.myconan.net/ec-userscripts/raw-file/tip/jiku-chu-direct-link.user.js
14
Edho Arief <me@myconan.net>
parents:
diff changeset
11 // ==/UserScript==
Edho Arief <me@myconan.net>
parents:
diff changeset
12
50
e8517cc75a74 Add https, update coding style
nanaya <me@nanaya.pro>
parents: 49
diff changeset
13 ;(function () {
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
14 'use strict'
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
15 const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]")
50
e8517cc75a74 Add https, update coding style
nanaya <me@nanaya.pro>
parents: 49
diff changeset
16 const removeOnClick = function (el) {
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
17 const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1')
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
18 const url = `/products/detail.php?product_id=${productId}`
33
Edho Arief <me@myconan.net>
parents: 19
diff changeset
19
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
20 el.setAttribute('href', url)
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
21 el.setAttribute('onclick', '')
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
22 }
33
Edho Arief <me@myconan.net>
parents: 19
diff changeset
23
66
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
24 Array.prototype.forEach.call(links, removeOnClick)
444b17e657be Standardize code style
nanaya <me@nanaya.pro>
parents: 58
diff changeset
25 }())