Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function iterOver(xp) {
- var i, item;
- for(i = 0; (item = xp.snapshotItem(i)); i++) {
- item.removeAttribute("data-hovercard");
- }
- }
- function setXpathListener(expr, func, context, onTimer) {
- var i, xp, arg, len, _int,
- _expr = (typeof expr === "string" ? expr : null),
- _func = (typeof func === "function" ? func : null),
- _context = (typeof context === "object" && context.nodeType === 1 ? context : document),
- _onTimer = (typeof onTimer === "boolean" ? onTimer : false);
- if(_onTimer === false) {
- for(i = 0; (arg = arguments[i]); i++) {
- switch(typeof arg) {
- case "boolean":
- if(!_onTimer && arg === true) _onTimer = true;
- break;
- case "function":
- if(!_func) _func = arg;
- break;
- case "string":
- if(!_expr) _expr = arg;
- break;
- case "object":
- if(!_context && arg.nodeType === 1) _context = arg;
- break;
- }
- }
- }
- if(typeof _expr !== "string" || typeof _func !== "function") return;
- xp = document.evaluate(_expr, _context, null, 6, null);
- len = xp.snapshotLength;
- if(len > 50) _int = 1750;
- else if(len > 25) _int = 1500;
- else if(len > 15) _int = 1250;
- else if(len > 5) _int = 1000;
- else if(len <= 5 && len !== 0) _int = 750;
- else if(len === 0) _int = 500;
- document.title = "int: " + _int + " - matches: " + len + " (" + Math.floor(Math.random() * 999) + ")";
- _func(xp); // run the user-specified function
- window.setTimeout(function() { // run this function again after some odd amount of time
- setXpathListener(_expr, _func, _context, true);
- }, _int);
- }
- var expr = "//a[@data-hovercard]/img/..";
- 1 && setXpathListener(expr, iterOver);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement