Advertisement
Nom1fan

Jump Yad2

Feb 10th, 2022 (edited)
1,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Yad2 jump ad
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://www.yad2.co.il/personal/posts
  8. // @icon         https://www.google.com/s2/favicons?domain=co.il
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. function reload() {
  13.     location.reload();
  14. }
  15.  
  16. function sleep(ms) {
  17.     return new Promise(resolve => setTimeout(resolve, ms));
  18. }
  19.  
  20. function getElementItertively(path) {
  21.     var element = null;
  22.     var maxRetries = 1000;
  23.     var i = 0;
  24.     do {
  25.         element = document.querySelector(path);
  26.         sleep(1000);
  27.         i++;
  28.     } while (element == null && i < maxRetries);
  29.     return element;
  30. }
  31.  
  32. function main() {
  33.     debugger;
  34.     'use strict';
  35.     var jumpBtn = getElementItertively("#root > main > div > section > ul:nth-child(4) > li > div.user-ad-wrapper.is-full-user-ad > article > div.user-ad-features > footer > div > button");
  36.     if (jumpBtn != null) {
  37.         var btnText = jumpBtn.innerText;
  38.         if (btnText == "הקפצה") {
  39.             jumpBtn.click();
  40.             var backToAdBtn = getElementItertively("#root > main > div > section > ul:nth-child(4) > li > div.common-popup-wrapper > section > div.common-popup-visual > div > div > button.u-flex-2.is-primary.common-button");
  41.             if (backToAdBtn != null) {
  42.                 backToAdBtn.click();
  43.             }
  44.         }
  45.     }
  46. }
  47.  
  48. window.addEventListener('load', function () {
  49.     main();
  50.     setInterval(reload, 360000);
  51. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement