Fossil SCM
New javascript for href.js such that any mousemove or mousedown event at any time is sufficient to trigger the mouse activity condition for activation of hyperlinks. This works better on FF and chrome, but with safari, the visited/unvisited link color is determined by the initial value of href= and is not adjusted when href= changes, so visited/unvisited colors are not being updated on safari.
Commit
e7d67b7640414f6e66e8d4b582dcb383270ea3b42e46a6805f7942ab3025b5ff
Parent
533c2c7144ad4bc…
1 file changed
+25
-12
+25
-12
| --- src/href.js | ||
| +++ src/href.js | ||
| @@ -15,14 +15,15 @@ | ||
| 15 | 15 | ** The <script> must have an id='href-data'. DELAY is the number |
| 16 | 16 | ** milliseconds delay prior to populating href= and action=. If the |
| 17 | 17 | ** mouseover boolean is true, then the href= rewrite is further delayed |
| 18 | 18 | ** until the first mousedown event that occurs after the timer expires. |
| 19 | 19 | */ |
| 20 | -var antiRobotOnce = 0; | |
| 21 | -function antiRobotSetAllHrefs(){ | |
| 22 | - if( antiRobotOnce ) return; | |
| 23 | - antiRobotOnce = 1; | |
| 20 | +var antiRobot = 0; | |
| 21 | +var antiRobotBody = document.getElementsByTagName("body")[0]; | |
| 22 | +function antiRobotGo(){ | |
| 23 | + if( antiRobot!=3 ) return; | |
| 24 | + antiRobot = 7; | |
| 24 | 25 | var anchors = document.getElementsByTagName("a"); |
| 25 | 26 | for(var i=0; i<anchors.length; i++){ |
| 26 | 27 | var j = anchors[i]; |
| 27 | 28 | if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 28 | 29 | } |
| @@ -30,22 +31,34 @@ | ||
| 30 | 31 | for(var i=0; i<forms.length; i++){ |
| 31 | 32 | var j = forms[i]; |
| 32 | 33 | if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action"); |
| 33 | 34 | } |
| 34 | 35 | } |
| 35 | -function antiRobotSetMouseEventHandler(){ | |
| 36 | - document.getElementsByTagName("body")[0].onmousedown=function(){ | |
| 37 | - antiRobotSetAllHrefs(); | |
| 38 | - document.getElementsByTagName("body")[0].onmousedown=null; | |
| 39 | - } | |
| 40 | -} | |
| 41 | 36 | function antiRobotDefense(){ |
| 42 | 37 | var x = document.getElementById("href-data"); |
| 43 | 38 | var jx = x.textContent || x.innerText; |
| 44 | 39 | var g = JSON.parse(jx); |
| 45 | 40 | if( g.mouseover ){ |
| 46 | - setTimeout(antiRobotSetMouseEventHandler, g.delay); | |
| 41 | + antiRobotBody.onmousedown=function(){ | |
| 42 | + antiRobot |= 2; | |
| 43 | + antiRobotGo(); | |
| 44 | + antiRobotBody.onmousedown=null; | |
| 45 | + } | |
| 46 | + antiRobotBody.onmousemove=function(){ | |
| 47 | + antiRobot |= 2; | |
| 48 | + antiRobotGo(); | |
| 49 | + antiRobotBody.onmousemove=null; | |
| 50 | + } | |
| 51 | + }else{ | |
| 52 | + antiRobot |= 2; | |
| 53 | + } | |
| 54 | + if( g.delay>0 ){ | |
| 55 | + setTimeout(function(){ | |
| 56 | + antiRobot |= 1; | |
| 57 | + antiRobotGo(); | |
| 58 | + }, g.delay) | |
| 47 | 59 | }else{ |
| 48 | - setTimeout(antiRobotSetAllHrefs, g.delay); | |
| 60 | + antiRobot |= 1; | |
| 49 | 61 | } |
| 62 | + antiRobotGo(); | |
| 50 | 63 | } |
| 51 | 64 | antiRobotDefense(); |
| 52 | 65 |
| --- src/href.js | |
| +++ src/href.js | |
| @@ -15,14 +15,15 @@ | |
| 15 | ** The <script> must have an id='href-data'. DELAY is the number |
| 16 | ** milliseconds delay prior to populating href= and action=. If the |
| 17 | ** mouseover boolean is true, then the href= rewrite is further delayed |
| 18 | ** until the first mousedown event that occurs after the timer expires. |
| 19 | */ |
| 20 | var antiRobotOnce = 0; |
| 21 | function antiRobotSetAllHrefs(){ |
| 22 | if( antiRobotOnce ) return; |
| 23 | antiRobotOnce = 1; |
| 24 | var anchors = document.getElementsByTagName("a"); |
| 25 | for(var i=0; i<anchors.length; i++){ |
| 26 | var j = anchors[i]; |
| 27 | if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 28 | } |
| @@ -30,22 +31,34 @@ | |
| 30 | for(var i=0; i<forms.length; i++){ |
| 31 | var j = forms[i]; |
| 32 | if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action"); |
| 33 | } |
| 34 | } |
| 35 | function antiRobotSetMouseEventHandler(){ |
| 36 | document.getElementsByTagName("body")[0].onmousedown=function(){ |
| 37 | antiRobotSetAllHrefs(); |
| 38 | document.getElementsByTagName("body")[0].onmousedown=null; |
| 39 | } |
| 40 | } |
| 41 | function antiRobotDefense(){ |
| 42 | var x = document.getElementById("href-data"); |
| 43 | var jx = x.textContent || x.innerText; |
| 44 | var g = JSON.parse(jx); |
| 45 | if( g.mouseover ){ |
| 46 | setTimeout(antiRobotSetMouseEventHandler, g.delay); |
| 47 | }else{ |
| 48 | setTimeout(antiRobotSetAllHrefs, g.delay); |
| 49 | } |
| 50 | } |
| 51 | antiRobotDefense(); |
| 52 |
| --- src/href.js | |
| +++ src/href.js | |
| @@ -15,14 +15,15 @@ | |
| 15 | ** The <script> must have an id='href-data'. DELAY is the number |
| 16 | ** milliseconds delay prior to populating href= and action=. If the |
| 17 | ** mouseover boolean is true, then the href= rewrite is further delayed |
| 18 | ** until the first mousedown event that occurs after the timer expires. |
| 19 | */ |
| 20 | var antiRobot = 0; |
| 21 | var antiRobotBody = document.getElementsByTagName("body")[0]; |
| 22 | function antiRobotGo(){ |
| 23 | if( antiRobot!=3 ) return; |
| 24 | antiRobot = 7; |
| 25 | var anchors = document.getElementsByTagName("a"); |
| 26 | for(var i=0; i<anchors.length; i++){ |
| 27 | var j = anchors[i]; |
| 28 | if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href"); |
| 29 | } |
| @@ -30,22 +31,34 @@ | |
| 31 | for(var i=0; i<forms.length; i++){ |
| 32 | var j = forms[i]; |
| 33 | if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action"); |
| 34 | } |
| 35 | } |
| 36 | function antiRobotDefense(){ |
| 37 | var x = document.getElementById("href-data"); |
| 38 | var jx = x.textContent || x.innerText; |
| 39 | var g = JSON.parse(jx); |
| 40 | if( g.mouseover ){ |
| 41 | antiRobotBody.onmousedown=function(){ |
| 42 | antiRobot |= 2; |
| 43 | antiRobotGo(); |
| 44 | antiRobotBody.onmousedown=null; |
| 45 | } |
| 46 | antiRobotBody.onmousemove=function(){ |
| 47 | antiRobot |= 2; |
| 48 | antiRobotGo(); |
| 49 | antiRobotBody.onmousemove=null; |
| 50 | } |
| 51 | }else{ |
| 52 | antiRobot |= 2; |
| 53 | } |
| 54 | if( g.delay>0 ){ |
| 55 | setTimeout(function(){ |
| 56 | antiRobot |= 1; |
| 57 | antiRobotGo(); |
| 58 | }, g.delay) |
| 59 | }else{ |
| 60 | antiRobot |= 1; |
| 61 | } |
| 62 | antiRobotGo(); |
| 63 | } |
| 64 | antiRobotDefense(); |
| 65 |