|
javascript:!function(){function e(e,o={}){const t={results:[],i:0,options:o={maxIterations:65536,maxDepth:8,verbose:!1,root:window,...o}};let r;return"function"==typeof e?r=e:(e=e.toString().toLowerCase(),r=function(o){return o.toString().toLowerCase().includes(e)}),function e(n,i){if(t.i++,i.length>=o.maxDepth)o.verbose&&console.log("Exceeded maximum depth (%i/%i), breaking...",i.length,o.maxDepth);else{o.verbose&&console.log("[%i] Scanning: %s",t.i,i.join("."));for(const s of Object.keys(n)){const a=n[s],c=[...i,s];if(n===a||a===o.root)continue;let l,u=o.root,m=!0;for(const e of i)if((u=u[e])===a){o.verbose&&console.log("Skipping %s, duplicate object",c.join(".")),m=!1;break}if(m){if(t.i>=t.options.maxIterations)return console.log("Exceeded maximum iterations (%i/%i), terminating...",t.i,o.maxIterations),!1;if(a&&("object"==typeof a?l=e(a,c):a&&r(a)&&t.results.push({obj:n,level:c.join("."),val:a}),!1===l))return!1}}}}(o.root,[]),t.results}console.log(["===[ Object Scanner ]===","See https://gist.github.com/Ratismal/8f2659bf7b0cf50a8fc9b8d8343f2b84 for usage instructions.","","Examples:","searchForTerm('term');","searchForTerm(function(value) {"," return value === 'term';","});","searchForTerm('term', {"," verbose: true,","});"].join("%5Cn"));try{window.searchForTerm=e}catch(o){try{global.searchForTerm=e}catch(e){console.error("Could not append searchForTerm to a global namespace (tried `window` and `global`)")}}}(); |