Advertisement
MrFrazSultan

Content

Oct 6th, 2023
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function InjectBar() {
  2.     var div = document.createElement("div");
  3.     div.innerHTML = `
  4.     <div class="mazepool-container">
  5.             <div flex item1>
  6.                 <span>How many Ads? </span>
  7.             </div>
  8.             <div flex item2>
  9.                 <input class="filterNumber numberField" type="number" value="10" >
  10.             </div>
  11.             <div flex item3>
  12.                 <button class="buttons filter-button"> Filter </button>
  13.             </div>
  14.             <div flex item5>
  15.                 <button class="buttons scroll-button"> Scroll</button>
  16.             </div>
  17.             <div flex item6>
  18.                 <span>Limit ads</span> <br>
  19.                 <span id="info-click" style="cursor:pointer"> </span>
  20.             </div>
  21.             <div flex-item7>
  22.                 <input class="maxAds numberField" type="number" value="50">
  23.             </div>
  24.             <div flex item9 results>
  25.                 <span class="scrollingStatus"></span>
  26.                 <br>
  27.                 <span class="foundAds"></span>
  28.             </div>
  29.         </div>
  30.     </div>
  31. `;
  32.     // Append the new element to the body of the page
  33.     document.body.appendChild(div);
  34.  
  35.     // Add CSS rules to the page
  36. }
  37.  
  38. function ActionsOnBar() {
  39.     // i toolip alert massage
  40.     let infoButton = document.getElementById("info-click");
  41.     infoButton.addEventListener("click", () => {
  42.         alert(
  43.             `Loading too many ads can slow down or freeze the Facebook Ads library.
  44.         That is why, the app will stop after the specified number of ads is found.
  45.         If you still find it to be slow, try lowering the number of ads you want to load at once.`
  46.         );
  47.     });
  48.  
  49.     // clear the text on the right of the bar
  50.     document.getElementsByClassName(
  51.         "x8t9es0 x1fvot60 xo1l8bm xxio538 x4hq6eo x1sdyfia x1h4wwuj xeuugli"
  52.     )[2].style.color = "white";
  53.  
  54.     // list of buttons
  55.     const filterBtn = document.getElementsByClassName("filter-button")[0];
  56.  
  57.     function filterAction() {
  58.         document.getElementsByClassName("filterNumber")[0].disabled = true;
  59.         let the = document.getElementsByClassName("filterNumber")[0].value;
  60.         the = parseInt(the);
  61.  
  62.         let time = 2000;
  63.         var intervalId = window.setInterval(function() {
  64.             var card = document.getElementsByClassName("_7jvw");
  65.             for (let ii = 0; ii < card.length; ii++) {
  66.                 var list = card[ii].getElementsByClassName(
  67.                     "x8t9es0 x1fvot60 xo1l8bm xxio538"
  68.                 );
  69.                 if (list.length == 0) {
  70.                     card[ii].parentElement.remove();
  71.                 }
  72.                 for (let i = 0; i < list.length; i++) {
  73.                     var num_text = parseInt(list[i].textContent);
  74.                     if (num_text < the) {
  75.                         card[ii].parentElement.remove();
  76.                     }
  77.                 }
  78.             }
  79.             console.log(the);
  80.         }, time);
  81.     }
  82.     filterBtn.addEventListener("click", () => {
  83.         filterAction();
  84.     });
  85.  
  86.     // What to do when clicked on scroll and stop
  87.     const scrollBtn = document.getElementsByClassName("scroll-button")[0];
  88.     if (scrollBtn) {
  89.         scrollBtn.addEventListener("click", function() {
  90.             console.log("scrollclick");
  91.  
  92.             if (
  93.                 document.getElementsByClassName("buttons scroll-button")[0]
  94.                 .innerText === "Stop"
  95.             ) {
  96.                 clearInterval(a);
  97.                 document.getElementsByClassName("filterNumber")[0].disabled = false;
  98.                 document.getElementsByClassName("scrollingStatus")[0].innerHTML =
  99.                     "Found";
  100.                 document.getElementsByClassName("buttons scroll-button")[0].innerText =
  101.                     "Scroll";
  102.             } else {
  103.                 a = setInterval(function() {
  104.                     window.scrollBy(0, 50);
  105.                 }, 100);
  106.                 document.getElementsByClassName("scrollingStatus")[0].innerHTML =
  107.                     "Finding Ads...";
  108.                 document.getElementsByClassName("buttons scroll-button")[0].innerText =
  109.                     "Stop";
  110.             }
  111.         });
  112.     }
  113. }
  114.  
  115. setTimeout(() => {
  116.     InjectBar();
  117.     ActionsOnBar();
  118. }, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement