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