Fossil

Check-in [5a62b395]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reverted [59c7ca0509]: drh says we can't use jQuery. Also, there was a syntax error that sent all hyperlinks to the honeypot in some conditions.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | js-hamburger-menu
Files: files | file ages | folders
SHA3-256: 5a62b395ed49d79e110ecf17cc9bd29b7372bd7d4976af173f4aba86db889982
User & Date: wyoung 2018-09-09 17:41:35.800
Context
2018-09-09
17:42
Merged in trunk improvements ... (check-in: 96b1a9ca user: wyoung tags: js-hamburger-menu)
17:41
Reverted [59c7ca0509]: drh says we can't use jQuery. Also, there was a syntax error that sent all hyperlinks to the honeypot in some conditions. ... (check-in: 5a62b395 user: wyoung tags: js-hamburger-menu)
2018-09-06
03:56
The hyperlinks in the hamburger menu drop-down still had the anti-robot defense activated. Defeated it. ... (check-in: 571df2e8 user: wyoung tags: js-hamburger-menu)
03:56
Converted src/href.js to jQuery as a demonstration: the code's nearly half the size, and it's clearer as a result. ... (check-in: 59c7ca05 user: wyoung tags: js-hamburger-menu)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/href.js.
14
15
16
17
18
19
20
21


22
23



24
25
26
27

28


29
30

31
32
33

34



35
**
** The <script> must have an id='href-data'.  DELAY is the number 
** milliseconds delay prior to populating href= and action=.  If the
** mouseover boolean is true, then the timer does not start until a
** mouse motion event occurs over top of the document.
*/
function setAllHrefs(){
  $('a[data-href]').attr('href', function() {


    return this.attr("data-href");
  });



  $('form[data-action]').attr('action'), function() {
    return this.attr("data-action");
  });
}

(function antiRobotDefense(){


  var g = JSON.parse($('#href-data').text());
  var hasMouseMove = 'onmousemove' in createElement('body');

  var initEvent = g.mouseover && hasMouseMove ? 'mousemove' : 'load';
  $('body').on(initEvent, function() {
    setTimeout(setAllHrefs, g.delay);

  });



})();







|
>
>
|
<
>
>
>
|
|
<
|
>
|
>
>
|
|
>
|
|
|
>
|
>
>
>
|
14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
**
** The <script> must have an id='href-data'.  DELAY is the number 
** milliseconds delay prior to populating href= and action=.  If the
** mouseover boolean is true, then the timer does not start until a
** mouse motion event occurs over top of the document.
*/
function setAllHrefs(){
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i<anchors.length; i++){
    var j = anchors[i];
    if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");

  }
  var forms = document.getElementsByTagName("form");
  for(var i=0; i<forms.length; i++){
    var j = forms[i];
    if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action");

  }
}
function antiRobotDefense(){
  var x = document.getElementById("href-data");
  var jx = x.textContent || x.innerText;
  var g = JSON.parse(jx);
  var isOperaMini =
       Object.prototype.toString.call(window.operamini)==="[object OperaMini]";
  if(g.mouseover && !isOperaMini){
    document.getElementByTagName("body")[0].onmousemove=function(){
      setTimeout(setAllHrefs, g.delay);
    }
  }else{
    setTimeout(setAllHrefs, g.delay);
  }
}
antiRobotDefense()