Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function InjectBar() {
- var div = document.createElement("div");
- div.innerHTML = `
- <div class="mazepool-container">
- <div flex item1>
- <span>How many Ads? </span>
- </div>
- <div flex item2>
- <input class="filterNumber numberField" type="number" value="10" >
- </div>
- <div flex item3>
- <button class="buttons filter-button"> Filter </button>
- </div>
- <div flex item5>
- <button class="buttons scroll-button"> Scroll</button>
- </div>
- <div flex item6>
- <span>Limit ads</span> <br>
- <span id="info-click" style="cursor:pointer"> </span>
- </div>
- <div flex-item7>
- <input class="maxAds numberField" type="number" value="50">
- </div>
- <div flex item9 results>
- <span class="scrollingStatus"></span>
- <br>
- <span class="foundAds"></span>
- </div>
- </div>
- </div>
- `;
- // Append the new element to the body of the page
- document.body.appendChild(div);
- // Add CSS rules to the page
- }
- function ActionsOnBar() {
- // i toolip alert massage
- let infoButton = document.getElementById("info-click");
- infoButton.addEventListener("click", () => {
- alert(
- `Loading too many ads can slow down or freeze the Facebook Ads library.
- That is why, the app will stop after the specified number of ads is found.
- If you still find it to be slow, try lowering the number of ads you want to load at once.`
- );
- });
- // clear the text on the right of the bar
- document.getElementsByClassName(
- "x8t9es0 x1fvot60 xo1l8bm xxio538 x4hq6eo x1sdyfia x1h4wwuj xeuugli"
- )[2].style.color = "white";
- // list of buttons
- const filterBtn = document.getElementsByClassName("filter-button")[0];
- function filterAction() {
- document.getElementsByClassName("filterNumber")[0].disabled = true;
- let the = document.getElementsByClassName("filterNumber")[0].value;
- the = parseInt(the);
- let time = 2000;
- var intervalId = window.setInterval(function() {
- var card = document.getElementsByClassName("_7jvw");
- for (let ii = 0; ii < card.length; ii++) {
- var list = card[ii].getElementsByClassName(
- "x8t9es0 x1fvot60 xo1l8bm xxio538"
- );
- if (list.length == 0) {
- card[ii].parentElement.remove();
- }
- for (let i = 0; i < list.length; i++) {
- var num_text = parseInt(list[i].textContent);
- if (num_text < the) {
- card[ii].parentElement.remove();
- }
- }
- }
- console.log(the);
- }, time);
- }
- filterBtn.addEventListener("click", () => {
- filterAction();
- });
- // What to do when clicked on scroll and stop
- const scrollBtn = document.getElementsByClassName("scroll-button")[0];
- if (scrollBtn) {
- scrollBtn.addEventListener("click", function() {
- console.log("scrollclick");
- if (
- document.getElementsByClassName("buttons scroll-button")[0]
- .innerText === "Stop"
- ) {
- clearInterval(a);
- document.getElementsByClassName("filterNumber")[0].disabled = false;
- document.getElementsByClassName("scrollingStatus")[0].innerHTML =
- "Found";
- document.getElementsByClassName("buttons scroll-button")[0].innerText =
- "Scroll";
- } else {
- a = setInterval(function() {
- window.scrollBy(0, 50);
- }, 100);
- document.getElementsByClassName("scrollingStatus")[0].innerHTML =
- "Finding Ads...";
- document.getElementsByClassName("buttons scroll-button")[0].innerText =
- "Stop";
- }
- });
- }
- }
- setTimeout(() => {
- InjectBar();
- ActionsOnBar();
- }, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement