Fossil SCM

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.

wyoung 2018-09-09 17:41 js-hamburger-menu
Commit 5a62b395ed49d79e110ecf17cc9bd29b7372bd7d4976af173f4aba86db889982
1 file changed +25 -14
+25 -14
--- src/href.js
+++ src/href.js
@@ -16,20 +16,31 @@
1616
** milliseconds delay prior to populating href= and action=. If the
1717
** mouseover boolean is true, then the timer does not start until a
1818
** mouse motion event occurs over top of the document.
1919
*/
2020
function setAllHrefs(){
21
- $('a[data-href]').attr('href', function() {
22
- return this.attr("data-href");
23
- });
24
- $('form[data-action]').attr('action'), function() {
25
- return this.attr("data-action");
26
- });
27
-}
28
-(function antiRobotDefense(){
29
- var g = JSON.parse($('#href-data').text());
30
- var hasMouseMove = 'onmousemove' in createElement('body');
31
- var initEvent = g.mouseover && hasMouseMove ? 'mousemove' : 'load';
32
- $('body').on(initEvent, function() {
21
+ var anchors = document.getElementsByTagName("a");
22
+ for(var i=0; i<anchors.length; i++){
23
+ var j = anchors[i];
24
+ if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
25
+ }
26
+ var forms = document.getElementsByTagName("form");
27
+ for(var i=0; i<forms.length; i++){
28
+ var j = forms[i];
29
+ if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action");
30
+ }
31
+}
32
+function antiRobotDefense(){
33
+ var x = document.getElementById("href-data");
34
+ var jx = x.textContent || x.innerText;
35
+ var g = JSON.parse(jx);
36
+ var isOperaMini =
37
+ Object.prototype.toString.call(window.operamini)==="[object OperaMini]";
38
+ if(g.mouseover && !isOperaMini){
39
+ document.getElementByTagName("body")[0].onmousemove=function(){
40
+ setTimeout(setAllHrefs, g.delay);
41
+ }
42
+ }else{
3343
setTimeout(setAllHrefs, g.delay);
34
- });
35
-})();
44
+ }
45
+}
46
+antiRobotDefense()
3647
--- src/href.js
+++ src/href.js
@@ -16,20 +16,31 @@
16 ** milliseconds delay prior to populating href= and action=. If the
17 ** mouseover boolean is true, then the timer does not start until a
18 ** mouse motion event occurs over top of the document.
19 */
20 function setAllHrefs(){
21 $('a[data-href]').attr('href', function() {
22 return this.attr("data-href");
23 });
24 $('form[data-action]').attr('action'), function() {
25 return this.attr("data-action");
26 });
27 }
28 (function antiRobotDefense(){
29 var g = JSON.parse($('#href-data').text());
30 var hasMouseMove = 'onmousemove' in createElement('body');
31 var initEvent = g.mouseover && hasMouseMove ? 'mousemove' : 'load';
32 $('body').on(initEvent, function() {
 
 
 
 
 
 
 
 
 
 
33 setTimeout(setAllHrefs, g.delay);
34 });
35 })();
 
36
--- src/href.js
+++ src/href.js
@@ -16,20 +16,31 @@
16 ** milliseconds delay prior to populating href= and action=. If the
17 ** mouseover boolean is true, then the timer does not start until a
18 ** mouse motion event occurs over top of the document.
19 */
20 function setAllHrefs(){
21 var anchors = document.getElementsByTagName("a");
22 for(var i=0; i<anchors.length; i++){
23 var j = anchors[i];
24 if(j.hasAttribute("data-href")) j.href=j.getAttribute("data-href");
25 }
26 var forms = document.getElementsByTagName("form");
27 for(var i=0; i<forms.length; i++){
28 var j = forms[i];
29 if(j.hasAttribute("data-action")) j.action=j.getAttribute("data-action");
30 }
31 }
32 function antiRobotDefense(){
33 var x = document.getElementById("href-data");
34 var jx = x.textContent || x.innerText;
35 var g = JSON.parse(jx);
36 var isOperaMini =
37 Object.prototype.toString.call(window.operamini)==="[object OperaMini]";
38 if(g.mouseover && !isOperaMini){
39 document.getElementByTagName("body")[0].onmousemove=function(){
40 setTimeout(setAllHrefs, g.delay);
41 }
42 }else{
43 setTimeout(setAllHrefs, g.delay);
44 }
45 }
46 antiRobotDefense()
47

Keyboard Shortcuts

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