1

i'm pretty much a complete js noob, and i'm trying to make a tampermonkey script that removes elements with a certain data attribute. i'm getting this error (Cannot set property 'display' of undefined), here's my code

(function() {
    var subscription_elements = [] //all subscription related page elements

    subscription_elements.push(document.querySelectorAll('[data-pulse-paywall-type="subscription"]')); //array, i think
    subscription_elements.push(document.getElementsByClassName('pks-product item'))

    console.log('Paywalled articles:');
    console.log(subscription_elements);

    subscription_elements.forEach(hide_article);

    function hide_article(item, index){
        item.style.display = 'none';
    };
})();

Edit: Solved! Unwrapping the array using ... turned out to be the solution.

Quesamo
  • 11
  • 3

0 Answers0