Ruan Yifeng's web log (how does http://www.ruanyifeng.com/blog/) detect that advertisements are blocked?

after AdBlock is enabled, the page does not display properly

Sep.08,2021

Adblock uses CSP technology, which does not allow the execution of inline-script, while teacher Ruan uses inline-script to load css files in his blog.

function loadjscssfile(filename, filetype){
    if (filetype=="js"){ //if filename is a external JavaScript file
        var fileref=document.createElement('script')
        fileref.setAttribute("type","text/javascript")
        fileref.setAttribute("src", filename)
    }
    else if (filetype=="css"){ //if filename is an external CSS file
        var fileref=document.createElement("link")
        fileref.setAttribute("rel", "stylesheet")
        fileref.setAttribute("type", "text/css")
        fileref.setAttribute("href", filename)
    }
    if (typeof fileref!="undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref)
}
//loadjscssfile("http://www.ruanyifeng.com/blog/styles.css", "css");
loadjscssfile('/static/themes/theme_scrapbook/theme_scrapbook.css', "css");

http://www.ruanyifeng.com/sta., this css file is not loaded, causing problems with the page style.

...
-sharpcontainer::before {
  display: none;
}
...

there is no detection, but some information is displayed when the advertisement does not come out.
see source code

-sharpcontainer::before {
  display: block;
  width: 100%;
  padding: 10px;
  background: rgba(0,0,0,0.1);
  text-align: center;
  content: "";
}

Menu