Update chrome.js

This commit is contained in:
Namhyeon Go 2021-08-17 05:12:02 +09:00 committed by GitHub
parent 0ce3e87c28
commit e06e7fac6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -559,18 +559,32 @@ var ChromeObject = function() {
;
} else {
var p = parseFloat(searchText.substring(searchText.indexOf('(') + 1, searchText.indexOf(')')));
s += '(function() {'
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '")).filter(function(x) {'
+ ' return (Math.random() < ' + p + ');'
+ ' });'
+ ' if (elements.length > 0) {'
+ ' var rect = elements[0].getBoundingClientRect();'
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
+ ' } else {'
+ ' return "";'
+ ' }'
+ '})()'
;
if (p > 0) {
s += '(function() {'
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '")).filter(function(x) {'
+ ' return (Math.random() < ' + p + ');'
+ ' });'
+ ' if (elements.length > 0) {'
+ ' var rect = elements[0].getBoundingClientRect();'
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
+ ' } else {'
+ ' return "";'
+ ' }'
+ '})()'
;
} else {
s += '(function() {'
+ ' var elements = Object.values(document.querySelectorAll("' + selector + '"));'
+ ' if (elements.length > 0) {'
+ ' var element = elements[Math.floor(Math.random() * elements.length)];';
+ ' var rect = element.getBoundingClientRect();'
+ ' return [parseInt(rect.left), parseInt(rect.top), parseInt(rect.x), parseInt(rect.y), parseInt(rect.right), parseInt(rect.bottom)].join(",");'
+ ' } else {'
+ ' return "";'
+ ' }'
+ '})()'
;
}
}
var result = this.getEvaluatedValue(s);