Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Script läuft nicht auf neuer Seite?
#3
und wenn ich jetzt richtig sehe würde ich die function in das document.ready machen .
so
Code:
// ==UserScript==
// @name         blabla
// @namespace    blabla
// @version      0.1
// @description  try to take over the world!
// @author       You
// @include  *google.de*
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// @run-at        document-end
// @grant        none
// ==/UserScript==

$(document).ready(function(){

    let urlhier = location.href;
    const reggooglemain =/https?:\/\/(www\.)?google.de(\/)?/;
    const reggoogleres=/https?:\/\/(www\.)?google.de(\/)search\?q\=.*/;
    //https://www.google.de/search?q=abc

    if(urlhier.match(reggooglemain)){google();return;}
    if(urlhier.match(reggoogleres)){location.reload();googleres();return;}


    async function google(){
        var ranstring=getrandomstring();
        location.replace("https://www.google.de/search?q="+ranstring);
    };

    async function googleres(){
        var links=document.querySelectorAll("a[href]");
        var wind=null;

        for(let i=0;i<3;i++){
            console.log("links[i]="+links[i]);
            wind=window.open(links[Math.floor(Math.random()*links.length)].href);
            //loop for
            //sleep
            //scroll
            for(let i=0;i<4;i++){
                try{
                    wind.scrollTo(200, 0);
                    await sleep(300);
                    wind.scroll(0,0);
                }catch(e){}

            }
            wind.close();
        }

    }

function getrandomstring() {
    var h=Math.floor(Math.random()*9);
    var result = '';
    var charactersup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    var characterslow='abcdefghijklmnopqrstuvwxyz';
    result = result+charactersup.charAt(Math.floor(Math.random() *
                                                   charactersup.length));

    for ( var i = 1; i < h; i++ ) {
        result += characterslow.charAt(Math.floor(Math.random() *
                                                  characterslow.length));
    }
    return result;
}

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

})
Hier sind alle meine Lösungen aus allen Foren. Ich helfe auch in Facebook-chat
Zitieren


Nachrichten in diesem Thema
RE: Script läuft nicht auf neuer Seite? - von admin - 22.07.2022, 21:14

Gehe zu:


Benutzer, die gerade dieses Thema anschauen:
1 Gast/Gäste