Customer Rule help

Discussion in 'Custom Filters' started by dudale, Dec 15, 2018.

  1. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    I view a web site.
    it include CSS, Javascript to detect ADBlock plugin
    I can't write the rule
    the site is:
    www[.]ruanyifeng[.]com /blog/2018/12/async-api-design.html

    CSS:
    HTML:
    <style>
    body {
      background-color: #f5f5d5;
    }
    
    #container::before {
      display: block;
      width: 100%;
      padding: 10px;
      background: rgba(0,0,0,0.1);
      text-align: center;
      content: "本站显示不正常,可能因为您使用了广告拦截器。";
    }
    
    </style>
    Javascript:
    HTML:
    <script type="text/javascript">
    
    function checker() {
    var img = document.querySelector('img[src^="http://www.ruanyifeng.com/blog/images"]');
      if (img && window.getComputedStyle(img).display === 'none'){
        var sponsor = document.querySelector('.entry-sponsor');
        var prompt = document.createElement('div');
        prompt.style = 'border: 1px solid #c6c6c6;border-radius: 4px;background-color: #f5f2f0;padding: 15px; font-size: 16px;';
      prompt.innerHTML = '<p>您使用了广告拦截器,导致本站内容无法显示。</p><p>请将 www.ruanyifeng.com 加入白名单,解除广告屏蔽后,刷新页面,谢谢。</p>';
        sponsor.parentNode.replaceChild(prompt, sponsor);
        document.querySelector('#main-content').innerHTML = '';
      }
    }
    
    setTimeout(checker, 1000);
    
    </script>
    I using two rules:
    ruanyifeng.com$$script[tag-content="checker"][max-length="100"]
    www.ruanyifeng.com/blog/checker.js

    But fail.

    Anyone can help me write the rule,
     
  2. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    I try three rules, but still fail.
    Code:
    div.banner:properties(content: /.*/)
    ||ruanyifeng.com$$script[tag-content="checker"][max-length="100"]
    www.ruanyifeng.com/blog/checker.js
    
    additional:
    Env: Windows, Chrome Plugin
     
    Last edited: Dec 15, 2018
  3. Alex302

    Alex302 Filters Developer Staff Member Administrator

    Joined:
    Jul 20, 2012
    Messages:
    24,655
    Please check
    Code:
    ||ruanyifeng.com/blog/checker.js
    
     
  4. Сергей Ильин

    Сергей Ильин Well-Known Member

    Joined:
    Dec 19, 2015
    Messages:
    2,322
    Can be try so
    Code:
    @@||ruanyifeng.com^$generichide
     
  5. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    It's not work :(
     
  6. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    It's Not work :(
     
  7. Blaz

    Blaz Moderator & Translator Staff Member Moderator

    Joined:
    Dec 21, 2014
    Messages:
    9,651
    URL block rule is not working as they have that content in their source code too.

    Chrome Extension does not support $$ rules.

    Please try these rules to hide ads and redefine adblock script:
    Code:
    ruanyifeng.com##div[style="display: inline-block ! important;width: 100%;"] a
    ruanyifeng.com##.entry-sponsor
    ruanyifeng.com#%#Object.defineProperty(window, 'checker', { get: function() { return -1; } });
    
    Though I can not reproduce the adblock message.
     
  8. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    It's work! thanks for your help.
    and It's only one rule is needed?

    Code:
    ruanyifeng.com#%#Object.defineProperty(window, 'checker', { get: function() { return -1; } })
     
  9. Blaz

    Blaz Moderator & Translator Staff Member Moderator

    Joined:
    Dec 21, 2014
    Messages:
    9,651
    Others are to hide ads
     
  10. dudale

    dudale New Member

    Joined:
    Dec 15, 2018
    Messages:
    6
    OH! Yes! It's great! :)