comparison jiku-chu-direct-link.user.js @ 109:ef21ef445fc6

Cleanups - wrap everything in function and call them last - fix namespace and update url
author nanaya <me@nanaya.net>
date Sun, 15 Jan 2023 23:33:41 +0900
parents 2c4470b73ad9
children d9dc190bccaf
comparison
equal deleted inserted replaced
108:2c4470b73ad9 109:ef21ef445fc6
1 // ==UserScript== 1 // ==UserScript==
2 // @name Jiku-Chu direct link 2 // @name Jiku-Chu direct link
3 // @namespace https://myconan.net 3 // @namespace https://nanaya.net
4 // @version 2.5.6 4 // @version 2.5.6
5 // @description Make proper link on Jiku-Chu pages 5 // @description Make proper link on Jiku-Chu pages
6 // @author nanaya 6 // @author nanaya
7 // @match http://www.jiku-chu.com/* 7 // @match http://www.jiku-chu.com/*
8 // @match https://www.jiku-chu.com/* 8 // @match https://www.jiku-chu.com/*
9 // @grant none 9 // @grant none
10 // @downloadURL https://hg.myconan.net/ec-userscripts/raw-file/tip/jiku-chu-direct-link.user.js 10 // @downloadURL https://hg.nanaya.net/ec-userscripts/raw-file/tip/jiku-chu-direct-link.user.js
11 // ==/UserScript== 11 // ==/UserScript==
12 12
13 (function () { 13 'use strict';
14 'use strict'; 14
15 function directLink () {
15 const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]"); 16 const links = document.querySelectorAll("a[onclick^=\"age_verification_submit('/products/detail.php?product_id=\"]");
16 const removeOnClick = function (el) { 17 const removeOnClick = function (el) {
17 const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1'); 18 const productId = el.getAttribute('onclick').replace(/.*product_id=(\d+).*/, '$1');
18 const url = `/products/detail.php?product_id=${productId}`; 19 const url = `/products/detail.php?product_id=${productId}`;
19 20
20 el.setAttribute('href', url); 21 el.setAttribute('href', url);
21 el.setAttribute('onclick', ''); 22 el.setAttribute('onclick', '');
22 }; 23 };
23 24
24 Array.prototype.forEach.call(links, removeOnClick); 25 Array.prototype.forEach.call(links, removeOnClick);
25 }()); 26 }
27
28 directLink();