remove target=_blank attributes with script

Discussion in 'Custom Filters' started by gobekli, Dec 29, 2018.

  1. gobekli

    gobekli New Member

    Joined:
    Dec 29, 2018
    Messages:
    3
    Hi,

    I wanted to remove all target=_blank attributes from links (<a href="..." target="_blank">), so I made a script rule:

    #%#Array.from(document.querySelectorAll('a[target="_blank"]')) .forEach(link => link.removeAttribute('target'));

    This script works with the Windows extension but not with the Android app.
    Why?
     
  2. Alex302

    Alex302 Filters Developer Staff Member Administrator

    Joined:
    Jul 20, 2012
    Messages:
    24,402
    Hi
    Which Android app - from Google Market or our site?
     
  3. gobekli

    gobekli New Member

    Joined:
    Dec 29, 2018
    Messages:
    3
    I use the Adguard app (Version 2.12.247) from your site and I have the proxy mode enabled. My device is a Sony Z4 tablet with Marshmallow 6.0.1
    Can you reproduce the behavior?
     
  4. Alex302

    Alex302 Filters Developer Staff Member Administrator

    Joined:
    Jul 20, 2012
    Messages:
    24,402
    Please check
    Code:
    #%#AG_onLoad(function() { Array.from(document.querySelectorAll('a[target="_blank"]')) .forEach(link => link.removeAttribute('target')); });
    
     
  5. gobekli

    gobekli New Member

    Joined:
    Dec 29, 2018
    Messages:
    3
    This works now also with Android. Thank you very much.