// ==UserScript== // @name zt-za Download all auto // @namespace https://greasyfork.org/fr/users/11667-hoax017 // @version 1.0.2 // @description zt-za Doanload All + zt-protect get link auto // @author Hoax017 // @match https://zt-protect.net/article/* // @match https://zt-protect.com/voirlien/* // @match https://zt-protect.com/telecharger/* // @match https://www.zt-za.com/*/* // @match https://www.zt-za.net/*/* // @screen http://prntscr.com/vo0rjt // @screen http://prntscr.com/vo0ruy // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; if (location.hostname.includes("zt-protect.com") || location.hostname.includes("zt-protect.net")) { // descript links if (location.pathname.indexOf("/telecharger") === 0 ) { let currentLink = document.querySelector('#single a') currentLink.href = currentLink.href.replace(/(\?|&)aff_id=\d+/,'').replace(/(\?|&)af=\d+/,''); currentLink.innerText = currentLink.href; if (document.querySelector('#single a')) { window.opener.parent.postMessage({ link : document.querySelector('#single a').href.replace(/(\?|&)aff_id=\d+/,'').replace(/(\?|&)af=\d+/,'')},"*"); window.close(); }; } else if (location.pathname.indexOf("/voirlien") === 0 || location.pathname.indexOf("/article") === 0) { setTimeout(function (){ if (document.querySelector(".btn.btn-primary")) document.querySelector(".btn.btn-primary").click(); }, 1000) } } else if (location.hostname.includes("zt-za.com") || location.hostname.includes("zt-za.net")) { // get all links var lines = Array.from(document.querySelectorAll('div.postinfo b')); var formatedData = []; var currentHost = null; let finalHostDlLinks = [] window.addEventListener("message", function (message) { if(message.origin !== "https://zt-protect.com") return ; finalHostDlLinks.push(message.data.link) }); const onClickActivator = function (e) { e.preventDefault(); let host = this.getAttribute('data-host'); let hostData = formatedData.find(function (e) {return e.host === host}); if (!hostData) return; finalHostDlLinks = []; let closedWindow = 0; for (const dlLink of hostData.links) { let win = open(dlLink); console.log(dlLink, host) let interval = setInterval(function () { if (win.closed) { closedWindow++; if (closedWindow === hostData.links.length) { alert(finalHostDlLinks.join("\n")); } clearInterval(interval); } }, 500) } }; for(const line of lines) { if(!line.innerText.includes('Episode') && !line.innerText.includes('Partie') && !line.innerText.includes('Télécharger')) { currentHost = line.innerText.trim(); if (formatedData.some(function (e) {return e.host === currentHost})) { currentHost += Math.floor(Math.random() * Math.floor(100)); } let activator = document.createElement('a'); activator.setAttribute('href', '#'); activator.setAttribute('data-host', currentHost); activator.setAttribute('style', 'margin-left:20px'); activator.innerText = "All" activator.addEventListener('click', onClickActivator) line.querySelector('div').append(activator); } else if (currentHost) { let linkBalises = line.querySelectorAll('a'); if (!linkBalises || !linkBalises.length) continue; for(let linkBalise of linkBalises) { let hostData = formatedData.find(function (e) {return e.host === currentHost}); if (hostData) { hostData.links.push(linkBalise.href) } else { formatedData.push({ host: currentHost, links: [linkBalise.href] }) } } } } } })();