NodeList-static-length-tampered.js (1003B)
1 "use strict"; 2 3 function makeStaticNodeList(length) { 4 const fooRoot = document.createElement("div"); 5 6 for (var i = 0; i < length; i++) { 7 const el = document.createElement("span"); 8 el.className = "foo"; 9 fooRoot.append(el); 10 } 11 12 document.body.append(fooRoot); 13 return fooRoot.querySelectorAll(".foo"); 14 } 15 16 const indexOfNodeList = new Function("nodeList", ` 17 const __cacheBust = ${Math.random()}; 18 19 const el = nodeList[50]; 20 21 let index = -1; 22 23 for (var i = 0; i < 1e5 / 2; i++) { 24 for (var j = 0; j < nodeList.length; j++) { 25 if (nodeList[j] === el) { 26 index = j; 27 break; 28 } 29 } 30 } 31 32 return index; 33 `); 34 35 const arrayIndexOfNodeList = new Function("nodeList", ` 36 const __cacheBust = ${Math.random()}; 37 38 const el = nodeList[50]; 39 const {indexOf} = Array.prototype; 40 41 for (var i = 0; i < 1e5; i++) { 42 var index = indexOf.call(nodeList, el); 43 } 44 45 return index; 46 `);