mileskitaro / Promoted Tweet Highlighter

// ==UserScript==
// @name         Promoted Tweet Highlighter
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Lets you know if a tweet is promoted and adds an easy block button
// @author       @mileskitaro
// @include      https://twitter.*
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    function adRed() {
        if (document.getElementById('stream-items-id') !== null) {
            var adList = document.getElementById('stream-items-id').querySelectorAll('div[data-promoted="true"]');
            if (adList !== null) {
                for (var i = 0; i < adList.length; i++) {
                    if (adList[i].innerHTML.includes("QuoteTweet") === false && adList[i].innerHTML.includes("Promoted Tweet Detected: Block") === false) {
                        adList[i].style.background = "#933";
                        console.log("Promoted Tweet HL: Red");
                        var turboTweeter = adList[i].getAttribute("data-screen-name");
                        adList[i].insertAdjacentHTML('afterbegin', '<button type="button" class="dropdown-link" role="menuitem"><li class="block-link js-actionBlock" data-nav="block" role="presentation" style="text-align:center; padding:10px; background:#500; color:#FFF"><u>Promoted Tweet Detected: Block <span class="username u-dir u-textTruncate" dir="ltr">@<b>' + turboTweeter + '?</u></b></span></li></button>');
                    }
                }
            }
        }
        var newLayoutAdList = document.querySelectorAll('svg[viewBox="0 0 24 24"][class="rn-111h2gw rn-4qtqp9 rn-yyyyoo rn-1qe8dj5 rn-ip8ujx rn-uyseuv rn-dnmrzs rn-bnwqim rn-m6rgpd rn-lrvibr"')
        for (var j = 0; j < newLayoutAdList.length; j++) {

            newLayoutAdList[j].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.background = "#933";
            //newLayoutAdList[j].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.insertAdjacentHTML('afterbegin','<li class="block-link js-actionBlock" data-nav="block" role="presentation" style="text-align:center; padding:10px; background:#500; color:#FFF"><button type="button" class="dropdown-link" role="menuitem"><u>Promoted Tweet Detected: Block <span class="username u-dir u-textTruncate" dir="ltr"><b>this brand?</u></b></span></button></li>');

        }
    }

    adRed();
    setInterval(function () {
        adRed();
    }, 1000);
})();

//<div class="rn-1awozwy rn-1efd50x rn-14skgim rn-rull8r rn-mm0ijv rn-13yce4e rn-fnigne rn-ndvcnb rn-gxnn5r rn-deolkf rn-6koalj rn-1qe8dj5 rn-1mlwlqe rn-18u37iz rn-61z16t rn-p1pxzi rn-11wrixw rn-156q2ks rn-ifefl9 rn-bcqeeo rn-wk8lta rn-9aemit rn-1mdbw0j rn-gy4na3 rn-bnwqim rn-1lgpqti"><svg viewBox="0 0 24 24" class="rn-111h2gw rn-4qtqp9 rn-yyyyoo rn-1qe8dj5 rn-ip8ujx rn-uyseuv rn-dnmrzs rn-bnwqim rn-m6rgpd rn-lrvibr"><g><path d="M20.75 2H3.25A2.25 2.25 0 0 0 1 4.25v15.5A2.25 2.25 0 0 0 3.25 22h17.5A2.25 2.25 0 0 0 23 19.75V4.25A2.25 2.25 0 0 0 20.75 2zM17.5 13.504a.875.875 0 1 1-1.75-.001V9.967l-7.547 7.546a.875.875 0 0 1-1.238-1.238l7.547-7.547h-3.54a.876.876 0 0 1 .001-1.751h5.65c.483 0 .875.39.875.874v5.65z"></path></g></svg><div class="rn-13yce4e rn-fnigne rn-ndvcnb rn-gxnn5r rn-deolkf rn-111h2gw rn-1471scf rn-14xgk7a rn-n6v787 rn-o11vmf rn-ebii48 rn-16dba41 rn-1sf4r6n rn-1mnahxq rn-61z16t rn-p1pxzi rn-11wrixw rn-bcqeeo rn-wk8lta rn-9aemit rn-1mdbw0j rn-gy4na3 rn-bauka4 rn-q42fyq rn-qvutc0" dir="auto">Promoted</div></div>

//<div class="rn-13yce4e rn-fnigne rn-ndvcnb rn-gxnn5r rn-deolkf rn-111h2gw rn-1471scf rn-14xgk7a rn-n6v787 rn-o11vmf rn-ebii48 rn-16dba41 rn-1sf4r6n rn-1mnahxq rn-61z16t rn-p1pxzi rn-11wrixw rn-bcqeeo rn-wk8lta rn-9aemit rn-1mdbw0j rn-gy4na3 rn-bauka4 rn-q42fyq rn-qvutc0" dir="auto">Promoted</div>