JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old 07.08.2024, 22:23
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,887
Default

@RydemStorm:
Update: I can reproduce, looking into it
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 07.08.2024 at 22:30.
Reply With Quote
  #3  
Old 07.08.2024, 22:29
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,887
Default

Found the culprit
Take a good look at
Quote:
if (name = "Links") assignment operator, always true
and now at
Quote:
if (name == "Links") equality operator
You're welcome
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 07.08.2024 at 22:32.
Reply With Quote
  #4  
Old 08.08.2024, 00:02
RydemStorm RydemStorm is offline
Vacuum Cleaner
 
Join Date: Jan 2023
Posts: 18
Default

Quote:
Originally Posted by Jiaz View Post
Found the culprit
Take a good look at

and now at

You're welcome
Jajajaja, it was my fault, sorry.
Reply With Quote
  #5  
Old 08.08.2024, 10:21
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,887
Default

Quote:
Originally Posted by RydemStorm View Post
Jajajaja, it was my fault, sorry.
Nothing to be sorry about. Sometimes you just can't see the forest because of too many trees
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

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 10:34.
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.