# HG changeset patch # User HIROSE Yuuji # Date 1565948009 -32400 # Node ID f480fa97fba6cdb634f5c055db6d89e0590c0f2c # Parent 9994bfb637e56a995c99f4b89083ee3c01c1ef1b Redirection also inserted by #XXX anchors diff -r 9994bfb637e5 -r f480fa97fba6 s4-main.js --- a/s4-main.js Fri Aug 16 17:33:38 2019 +0900 +++ b/s4-main.js Fri Aug 16 18:33:29 2019 +0900 @@ -26,6 +26,9 @@ else lines = [""]; var re = new RegExp("[, ]*#"+articleId+"(?![0-9])"); + checked = (p.nodeName.match(/^input$/) + ? p.checked // checkbox obeys its status + : !lines[0].match(re)) // a-elment toggles redirection if (checked) { if (!lines[0].match(re)) { var re2 = new RegExp(/>#[#0-9, ]+[0-9]/); @@ -51,12 +54,16 @@ textarea.value = lines.join("\n"); } } - function init(){ + function init() { var el, check = collectElementsByNameAttr("input", "notifyto"); if (check) - for (var i of check) { + for (let i of check) { i.addEventListener("click", insertRedirect, null); } + for (let i of document.getElementsByTagName("a")) + if (i.getAttribute("href").match(/^#[0-9]+$/)) + if (RegExp.lastMatch == i.innerHTML) + i.addEventListener("click", insertRedirect, null) } document.addEventListener('DOMContentLoaded', init, null); })();