ladroop / promotion free twitter

// ==UserScript==
// @name        promotion free twitter
// @namespace   twitter_goes_droopy
// @description hides promoted tweets
// @include     https://twitter.com/*
// @version     1.0
// @run-at      document-start
// @copyright   2020, ladroop (https://openuserjs.org/users/ladroop)
// @updateURL   https://openuserjs.org/meta/ladroop/promotion_free_twitter.meta.js
// @downloadURL https://openuserjs.org/install/ladroop/promotion_free_twitter.user.js
// @license     MIT
// @grant       none
// ==/UserScript==


(function() {
    'use strict';

var n=0;
var m=0;
var i=0;
var names=["Promoted","Uitgelicht","Gesponsert","Promocionado"];
var adds=[];
var adds2=[];
var foundname="";
var observer = new MutationObserver(cleanup);
var observerConfig = {subtree:true, childList:true};
var observenode=document.querySelector("body");
observer.observe(observenode, observerConfig);

	function cleanup(){
		adds=document.querySelectorAll("div[data-testid='placementTracking']"); // this can be add's
		for (n=0;n<adds.length ; n++){
            if (adds[n].style.display!="none"){// already hidden
                adds2=adds[n].getElementsByTagName("span"); // get all span tags in possible add's
                for (m=0;m<adds2.length ; m++){ // check all span tags for language dependend message
                    if (foundname==""){ // don't know yet what language
                        for (i=0;i<names.length ; i++){
                            if (adds2[m].innerHTML==names[i]){ // found an add
                                adds[n].style.display="none"; // hide it
                                foundname=names[i]; // now i also know what language
                                break; //stop search in languages
                            }
                            if (foundname!=""){// stop searching in spans tags if found
                                break;
                            }
                        }
                    }else{ // i know what language
                        if (adds2[m].innerHTML==foundname){ // found add
                            adds[n].style.display="none"; // hide it
                            break;// stop searching in span tags
                        }
                    }
                }
            }
        }
    }

})();