JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 19.01.2024, 21:31
hvhvhv hvhvhv is offline
I will play nice!
 
Join Date: Jan 2024
Posts: 1
Default Permissions Required popup doesn't work

Hi, I'm writing an event script which calls setPriority through the API to change a download/package priority. As expected, on first execution it causes the permissions popup to appear before the script can proceed. I am unable to click on anything in this popup using the mouse or keyboard controls. Attempting to close/dismiss the window using the controls at the top left, ctrl-f4, or using the red x is ineffective and I have to kill JDownloader with task manager to close the program.

I've checked to make sure that there are no other popups spawned beneath it that might have priority (I've seen that suggested before).

I haven't done any scripting on other versions so I don't know if this problem was present previously or just started occurring.

Java Runtime: 1.8.0_40
JD2 Core: 48254
JD2 Build Date: Tue Jan 16 15:38:24 CET 2024
Reply With Quote
  #2  
Old 23.01.2024, 13:44
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,260
Default

I can't reproduce this here.
Please provide a log and a screen cast video of this problem.

Please post your log-ID here
If your bugreport is about a specific website which JD supports via plugin, please also provide example URLs which can be used to reproduce the issue you are having.

Bitte poste deine Log-ID hier.
Falls dein gemeldetes Problem ein Problem mit einer Webseite ist, die per Plugin unterstützt wird, stelle bitte zusätzlich Testlinks zur Verfügung, mit denen sich dein Problem nachstellen lässt.

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?

-----------------------------------

On Vacation / Im Urlaub
Start: 2024-02-08
End: TBA

Reply With Quote
  #3  
Old 06.04.2024, 23:45
johndoe johndoe is offline
Modem User
 
Join Date: Apr 2024
Posts: 4
Default

Hi!

I hope it's ok to respond to someone else's ticket but I'm having the same issue.

I'm trying to call getClipboard through the callAPI and the buttons on the permissions window is not clickable and there's no way to close it. The only way to close it is to use task manager to kill JDownloader.

This is the function I'm using in script editor:
var oldClipboardContent = callAPI("system", "getClipboard");


Here's a video showing the nothing is clickable:
**External links are only visible to Support Staff****External links are only visible to Support Staff**
Reply With Quote
  #4  
Old 07.04.2024, 13:43
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,918
Default

@johndoe: on which trigger is the script? anything from GUI, like button/context menu action?
Most likely the dialog is causing a deadlock in GUI as the GUI is waiting to process it's queue while the script is blocking the GUI and waiting for the user to confirm the dialog. maybe we should abort script here, then show dialog and then restart script

@johndoe
@hvhvhv
You can also disable those permission checks within the script
Quote:
disablePermissionChecks();/*disable permission checks*/
__________________
JD-Dev & Server-Admin
Reply With Quote
  #5  
Old 07.04.2024, 14:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,560
Default

Quote:
Originally Posted by johndoe View Post
callAPI("system", "getClipboard");
Not sure if 'getClipboard' is a valid MYJD API call. Where did you find/read about it?
Reply With Quote
  #6  
Old 07.04.2024, 15:53
johndoe johndoe is offline
Modem User
 
Join Date: Apr 2024
Posts: 4
Default

Hello!

I was using the trigger "A new link has been added".

I used ChatGPT to generate the script. I wasn't sure if the function was available or it hallucinated it so I was trying to test but the permissions window was blocking any real testing.

I was trying to create a script that automates some downloading I do manually. I have a page that I copy the URL from for the file and then then then I have to copy the client name from the label above to save the package to the correct folder.

I was trying to find a way to automate this by watching when a link was added for a specific host, and watch the clipboard for 10 seconds to see if the clipboard changed and if it did, then replace the path with the client's name.

The server generates random file names using guids so I was unable to do anything with that so I thought this might be a solve.

I just tested the disablePermissionsCheck() function but the script throws an error dialog with the same issue where the buttons are not clickable. I took a screenshot of the error and here's the extracted text:

Quote:
An Error Occured:ID=1712394692488|Name=Set Download Folder|Trigger=ON_NEW_LINK

Wrapped org.jdownloader.extensions.eventscripter.EnvironmentException: Line 29
java.lang.NullPointerException
at org.jdownloader.api.RemoteAPIController.call(RemoteAPIController,java:751)
at org.jdownloader.extensions.eventscripter.sandboxobjects.ScriptEnvironment.callAPI(ScriptEnvironment. java:232)
at sun.reflect.NativeMethodAccessorlmpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorlmpl.invoke(NativeMethodAccessorlmpl.java:62)
at sun.reflect.DelegatingMethodAccessorlmpl.invoke(DelegatingMethodAccessorlmpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:153)
at net.sourceforge.htmlunit.corejs.javascript.NativeJavaMethod.call(NativeJavaMethod.java:213)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1536)
at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
at org.jdownloader.scripting.JSHtmlUnitPermissionRestricter$SandboxContextFactory.doTopCall(JSHtmIUnitP ermissionRestricter.java:134)
at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3286)
at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction,java:115)
at net.sourceforge.htmlunit.corejs.javascript.Context.evaluateString(Context.java:1361)
at org.jdownloader.extensions.eventscripter.ScriptThread.evalUNtrusted(ScriptThread.java:344)
at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:192)
at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:167)

X

(#29)

Ok

Error details
Here's the script:

Code:
// Trigger: A new link has been added
// Note: Make sure to enable "Advanced Settings" and then find this script in Event Scripter to select "Trigger: New Links" from the dropdown.

var defaultFolderPath = "D:\\Reports\\Clients\\Temp\\<jd:packagename>"; // Default save path before replacement
var clipboardMonitoringTime = 10000; // 10 seconds in milliseconds

// Function to set the new package name and modify the save directory
function setPackageNameAndModifySaveDirectory(newPackageName) {
    var packages = callAPI("linkgrabberv2", "getPackages");
    if (packages.length > 0) {
        var lastPackage = packages[packages.length - 1]; // Assuming the last added package is the one we want to rename
        var packageName = lastPackage.name;
        
        // Extract the first part of the string before the first "-"
        var newName = newPackageName.split("-")[0].trim();
        var newFolderPath = defaultFolderPath.replace("Temp", newName) + packageName;
        
        // Update package name and folder path
        callAPI("linkgrabberv2", "setPackageName", lastPackage.uuid, newName);
        callAPI("linkgrabberv2", "setDownloadDirectory", lastPackage.uuid, newFolderPath);
    }
}

// Main logic
if (link.getHost() === 'server.com') {
    // Start monitoring the clipboard
    var endTime = new Date().getTime() + clipboardMonitoringTime;
    var oldClipboardContent = callAPI("system", "getClipboard");
    
    var checkClipboard = setInterval(function() {
        var currentClipboardContent = callAPI("system", "getClipboard");
        alert(currentClipboardContent);
        if (currentClipboardContent !== oldClipboardContent && !currentClipboardContent.startsWith("http")) {
            // New non-URL content detected in clipboard, update package name and directory
            setPackageNameAndModifySaveDirectory(currentClipboardContent);
            clearInterval(checkClipboard); // Stop monitoring the clipboard
        }
        
        if (new Date().getTime() > endTime) {
            // Stop checking after the specified time
            clearInterval(checkClipboard);
        }
    }, 500); // Check the clipboard every 500 milliseconds
}

Last edited by johndoe; 07.04.2024 at 15:58.
Reply With Quote
  #7  
Old 07.04.2024, 16:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,560
Default

Quote:
Originally Posted by johndoe View Post
... the permissions window was blocking any real testing.

... the script throws an error dialog with the same issue where the buttons are not clickable.
While using a script with "a new link has been added" trigger, "synchronous execution of script" checkbox must be disabled.

Looks like ChatGP plucked most of the API calls in the script from thin air.

You don't need to check the clipboard at regular intervals. 'new link has been added' will be triggered everytime a new link is added to JD. You can also try "new crawler job" and "packagizer hook' triggers.
Reply With Quote
  #8  
Old 07.04.2024, 19:28
johndoe johndoe is offline
Modem User
 
Join Date: Apr 2024
Posts: 4
Default

Hi @mgpai!

Thanks! Disabling synchronous execution of script fixes the unclickable dialog boxes.

Do you have any advice on how would you implement what I'm trying to do? I was trying to monitor the clipboard because the 2nd clipboard event would be the client name.

So the workflow would be:

1) Copy the link to the file
1a) JD adds the link to linkgrabber.
2) Get the client name from the 2nd copy from clipboard.
3) Update the temp in the default path to the client name (or set the path)

I could copy the also text with the link in the first batch if JD makes that available to the script in the crawler or packagizer like and then split it out.

For example, the initial text to parse can be:
Client Name: server.com/report.xlsx

The name would always be in the same format before the : so I could easily parse that if there's a way to get the entire string and set the path.

I sincerely appreciate you taking the time to reply and help.

Thanks!
Reply With Quote
  #9  
Old 07.04.2024, 19:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,560
Default

Append the client name and any other strings you want to parse at the end of the url, and use packagizer to set pacakgename/downloadfolder/filename etc.
Reply With Quote
  #10  
Old 07.04.2024, 20:58
johndoe johndoe is offline
Modem User
 
Join Date: Apr 2024
Posts: 4
Default

@mgpai, thanks so much! I didn't even know packagizer was a thing. It solved my needs.
Reply With Quote
  #11  
Old 07.04.2024, 21:17
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,918
Default

@johndoe: You could also make use of Crawljobs/Folderwatch, see
https://support.jdownloader.org/de/k...ch-basic-usage

Maybe you can also share your solution so others can learn from it

@mgpai: Thanks for your help
__________________
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 08:41.
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.