JDownloader Community - Appwork GmbH
 

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07.08.2024, 21:37
RydemStorm RydemStorm is offline
Vacuum Cleaner
 
Join Date: Jan 2023
Posts: 18
Default Button trigger several event scripts, skip restrictions name

LogId:
07.08.24 15.17.14 <--> 07.08.24 15.28.56 jdlog://3764411370661/
Problem:
I implemented two Event Scripts, each one should be executed by an "EventScripter Trigger" button.
In the Code of the Event Script I validate that the Name of the button corresponds to the one I want to execute the Script.
However, I noticed that both scripts are executed, regardless of which button I click on.

Code:
if (name = "Links") {
    var links = "";
    for (var i = 0; i < getAllDownloadLinks().length; i++) {
        var package = getAllDownloadLinks()[i];
        links = links + package.getName() + ":" + package.getContentURL() + "\r";
    }
    alert(links)
}
Code:
if (name = "Favorites") {
    var favorites = ["mega.nz", "streamtape.com", "gofile.io", "send.cm"];

    function getFavoriteIndex(domain) {
        for (var i = 0; i < favorites.length; i++) {
            if (favorites[i] === domain) {
                return i;
            }
        }
        return -1;
    }
    for (var i = 0; i < getAllCrawledPackages().length; i++) {
        var best = -1;
        var package = getAllCrawledPackages()[i];
        for (var j = 0; j < package.getDownloadLinks().length; j++) {
            var link = package.getDownloadLinks()[j];
            var domain = link.getContentURL().split('/')[2];
            var favorite = getFavoriteIndex(domain);
            if (favorite >= 0 && (best == -1 || best > favorite)) {
                best = favorite;
            }
        }
        for (var j = 0; j < package.getDownloadLinks().length; j++) {
            var link = package.getDownloadLinks()[j];
            var domain = link.getContentURL().split('/')[2];
            link.setEnabled(best == -1 || favorites[best] == domain);
            if (best > -1) {
                link.setPriority("HIGHEST");
            }
        }
    }
}
Attached Images
File Type: png 01.png (71.3 KB, 1 views)
File Type: png 02.png (179.2 KB, 1 views)
File Type: png 03.png (111.5 KB, 1 views)
File Type: png 04.png (54.1 KB, 1 views)

Last edited by Jiaz; 07.08.2024 at 22:25.
Reply With Quote
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 07:27.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.