Ruanyifeng No Block AdBlock

防止阮一峰博客屏蔽AdBlock

Install this script?
Author's suggested script

You may also like RemoveAds.

Install this script
Author
Xzonn
Daily installs
0
Total installs
48
Ratings
0 0 0
Version
0.1
Created
2022-07-01
Updated
2022-07-01
License
WTFPL
Applies to

阮一峰博客检测广告的核心代码为:

  if (
    /*isAdblocker || */
    (img && window.getComputedStyle(img).display === 'none') ||
    (img && window.getComputedStyle(img.parentElement).display === 'none')
  )

注意到这段代码是通过setTimeout(checker, 1000);执行的,因此只需要把window.getComputedStyle这个函数修改掉就可以了。

核心代码:

window.getComputedStyle = function() { return { "display": "block" }; }