Fossil

Check-in [59c7ca05]
Login

Check-in [59c7ca05]

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

Overview
Comment:Converted src/href.js to jQuery as a demonstration: the code's nearly half the size, and it's clearer as a result.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | js-hamburger-menu
Files: files | file ages | folders
SHA3-256: 59c7ca0509e49872a09f3a89bb6cc55a72ca483c24e4bc720205bac3af6f3f7f
User & Date: wyoung 2018-09-06 03:56:00
References
2018-09-09
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)
Context
2018-09-09
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)
2018-09-05
23:45
Fixed a bug in the onclick handler for the new hamburger button which allowed the browser to follow our empty 'a href="#"' link. For some reason, Chrome only did this sometimes, not always, which lead to me thinking it was some kind of race condition. ... (check-in: e806e5c4 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
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()







|
<
<
|
|
<
<
|
|
|

|
<
<
|
|
<
|
|
|
|
<
<
|
<
<
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);
  });


})();