Fossil SCM

Simplification to the JS used as part of anti-robot defenses.

drh 2022-09-30 12:38 trunk
Commit 08535b229e39e4648418f00a70e2f2cd5cea1485d239da68ca75a953ee8f7d2d
1 file changed +4 -5
+4 -5
--- src/href.js
+++ src/href.js
@@ -16,11 +16,10 @@
1616
** milliseconds delay prior to populating href= and action=. If the
1717
** mouseover boolean is true, then the href= rewrite is further delayed
1818
** until the first mousedown event that occurs after the timer expires.
1919
*/
2020
var antiRobot = 0;
21
-var antiRobotBody = document.getElementsByTagName("body")[0];
2221
function antiRobotGo(){
2322
if( antiRobot!=3 ) return;
2423
antiRobot = 7;
2524
var anchors = document.getElementsByTagName("a");
2625
for(var i=0; i<anchors.length; i++){
@@ -36,19 +35,19 @@
3635
function antiRobotDefense(){
3736
var x = document.getElementById("href-data");
3837
var jx = x.textContent || x.innerText;
3938
var g = JSON.parse(jx);
4039
if( g.mouseover ){
41
- antiRobotBody.onmousedown=function(){
40
+ document.body.onmousedown=function(){
4241
antiRobot |= 2;
4342
antiRobotGo();
44
- antiRobotBody.onmousedown=null;
43
+ document.body.onmousedown=null;
4544
}
46
- antiRobotBody.onmousemove=function(){
45
+ document.body.onmousemove=function(){
4746
antiRobot |= 2;
4847
antiRobotGo();
49
- antiRobotBody.onmousemove=null;
48
+ document.body.onmousemove=null;
5049
}
5150
}else{
5251
antiRobot |= 2;
5352
}
5453
if( g.delay>0 ){
5554
--- src/href.js
+++ src/href.js
@@ -16,11 +16,10 @@
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++){
@@ -36,19 +35,19 @@
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
--- src/href.js
+++ src/href.js
@@ -16,11 +16,10 @@
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 function antiRobotGo(){
22 if( antiRobot!=3 ) return;
23 antiRobot = 7;
24 var anchors = document.getElementsByTagName("a");
25 for(var i=0; i<anchors.length; i++){
@@ -36,19 +35,19 @@
35 function antiRobotDefense(){
36 var x = document.getElementById("href-data");
37 var jx = x.textContent || x.innerText;
38 var g = JSON.parse(jx);
39 if( g.mouseover ){
40 document.body.onmousedown=function(){
41 antiRobot |= 2;
42 antiRobotGo();
43 document.body.onmousedown=null;
44 }
45 document.body.onmousemove=function(){
46 antiRobot |= 2;
47 antiRobotGo();
48 document.body.onmousemove=null;
49 }
50 }else{
51 antiRobot |= 2;
52 }
53 if( g.delay>0 ){
54

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button