Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Chartbeat flicker control div's #3913

Merged
merged 1 commit into from Feb 13, 2024
Merged

Conversation

ryanbr
Copy link
Contributor

@ryanbr ryanbr commented Feb 13, 2024

Chartbeat is using "hide the screen for a few sec, until the script loads"

https://publicwww.com/websites/%22chartbeat-flicker-control-style%22/

As seen on https://www.politico.com/ https://www.welt.de/ https://www.rottentomatoes.com/

<style type="text/css" id="chartbeat-flicker-control-style">body { visibility: hidden !important; }</style><script type="text/javascript">
(function() {
var _sf_async_config = window._sf_async_config = (window._sf_async_config || {});
_sf_async_config.uid = 33430;
_sf_async_config.domain = 'www.politico.com';
_sf_async_config.useCanonical = true;
window.setTimeout(function() {
    var hider = document.getElementById('chartbeat-flicker-control-style');
    if (hider) {
        hider.parentNode.removeChild(hider);
    }
}, 1000);
})();</script>
<script src="//static.chartbeat.com/js/chartbeat_mab.js"></script>

Alternative version:

(function() {
    'use strict';
    const noopfn = function() {
    };
    window.pSUPERFLY = {
        activity: noopfn,
        virtualPage: noopfn
    };
    const flickerElm = document.querySelector('[id^=chartbeat-flicker-control]')
    if (flickerElm) {
        const replacementElm = document.createElement(flickerElm.tagName)
        for (const attrName of ['id', 'type', 'className']) {
            if (flickerElm[attrName]) {
                replacementElm[attrName] = flickerElm[attrName]
            }
        }
        flickerElm.replaceWith(replacementElm)
    }
})()

@gorhill gorhill merged commit 397d6d4 into gorhill:master Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants