Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Yad2 jump ad
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://www.yad2.co.il/personal/posts
- // @icon https://www.google.com/s2/favicons?domain=co.il
- // @grant none
- // ==/UserScript==
- function reload() {
- location.reload();
- }
- function sleep(ms) {
- return new Promise(resolve => setTimeout(resolve, ms));
- }
- function getElementItertively(path) {
- var element = null;
- var maxRetries = 1000;
- var i = 0;
- do {
- element = document.querySelector(path);
- sleep(1000);
- i++;
- } while (element == null && i < maxRetries);
- return element;
- }
- function main() {
- debugger;
- 'use strict';
- 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");
- if (jumpBtn != null) {
- var btnText = jumpBtn.innerText;
- if (btnText == "הקפצה") {
- jumpBtn.click();
- 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");
- if (backToAdBtn != null) {
- backToAdBtn.click();
- }
- }
- }
- }
- window.addEventListener('load', function () {
- main();
- setInterval(reload, 360000);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement