mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Defuse fixed position on body element in element zapper
The `fixed` style property on the `body` element will be defused if an overlay element is removed using the element zapper. Related: - https://www.reddit.com/r/uBlockOrigin/comments/bktxtb/scrolling_doesnt_work/emlscyz
This commit is contained in:
parent
26237d6d40
commit
e59bdb1485
1 changed files with 25 additions and 5 deletions
|
|
@ -1259,18 +1259,38 @@ const showDialog = function(options) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
// https://www.reddit.com/r/uBlockOrigin/comments/bktxtb/scrolling_doesnt_work/emn901o
|
||||
// Override 'fixed' position property on body element if present.
|
||||
|
||||
const zap = function() {
|
||||
if ( targetElements.length === 0 ) { return; }
|
||||
|
||||
const getStyleValue = function(elem, prop) {
|
||||
const style = window.getComputedStyle(elem);
|
||||
return style ? style[prop] : '';
|
||||
};
|
||||
|
||||
let elem = targetElements[0];
|
||||
const style = window.getComputedStyle(elem);
|
||||
// Heuristic to detect scroll-locking: remove such lock when detected.
|
||||
if ( parseInt(style.zIndex, 10) >= 1000 || style.position === 'fixed' ) {
|
||||
document.body.style.setProperty('overflow', 'auto', 'important');
|
||||
document.documentElement.style.setProperty('overflow', 'auto', 'important');
|
||||
if (
|
||||
parseInt(getStyleValue(elem, 'zIndex'), 10) >= 1000 ||
|
||||
getStyleValue(elem, 'position') === 'fixed'
|
||||
) {
|
||||
const doc = document;
|
||||
if ( getStyleValue(doc.body, 'overflowY') === 'hidden' ) {
|
||||
doc.body.style.setProperty('overflow', 'auto', 'important');
|
||||
}
|
||||
if ( getStyleValue(doc.body, 'position') === 'fixed' ) {
|
||||
doc.body.style.setProperty('position', 'static', 'important');
|
||||
}
|
||||
if ( getStyleValue(doc.documentElement, 'overflowY') === 'hidden' ) {
|
||||
doc.documentElement.style.setProperty('overflow', 'auto', 'important');
|
||||
}
|
||||
}
|
||||
|
||||
elem.parentNode.removeChild(elem);
|
||||
elem = elementFromPoint();
|
||||
highlightElements(elem ? [elem] : []);
|
||||
highlightElements(elem ? [ elem ] : []);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in a new issue