Mercurial > ec-userscripts
comparison jiku-chu-direct-link.user.js @ 117:d9dc190bccaf
Undo combining fixes into single script per site
| author | nanaya <me@nanaya.net> |
|---|---|
| date | Sun, 15 Jan 2023 23:49:35 +0900 |
| parents | ef21ef445fc6 |
| children | 8de2d53a4cb1 |
comparison
equal
deleted
inserted
replaced
| 116:0e108a9dc6d7 | 117:d9dc190bccaf |
|---|---|
| 10 // @downloadURL https://hg.nanaya.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 'use strict'; | 13 'use strict'; |
| 14 | 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}`; | |
| 20 | 19 |
| 21 el.setAttribute('href', url); | 20 el.setAttribute('href', url); |
| 22 el.setAttribute('onclick', ''); | 21 el.setAttribute('onclick', ''); |
| 23 }; | 22 }; |
| 24 | 23 |
| 25 Array.prototype.forEach.call(links, removeOnClick); | 24 Array.prototype.forEach.call(links, removeOnClick); |
| 26 } | |
| 27 | |
| 28 directLink(); |
