#1121
|
|||
|
|||
![]() Quote:
Quote:
You can use the regex to only match file name string. To check if file exists, you have to use 'flilePath.exists()' method. Get the contents of the folder using 'filePath.getChildren()' method and filter them using your pattern. This will eliminate the need for file exists check, since it will return only the contents which exist on the disk. |
#1122
|
|||
|
|||
![]()
thanks master!
Is there a way to move selected file or package from Downloads back to LinkGrabber? Also would like to move finished files from the selected package to (original packageName + 'DONE') |
#1123
|
|||
|
|||
![]() Code:
//@mgpai //Packagizer Alt Filters // Trigger: Packagizer Hook var fn = link.getName(); var pn; if (!pn && /birds|elephant/.test(fn)) pn = "animals"; if (!pn && /bmw|honda|tesla/.test(fn)) pn = "cars"; if (!pn && /.*\.(pdf|epub|mobi)$/.test(fn)) pn = "ebooks"; if (pn) link.setPackageName(pn); When you brought up there is a possibility to exit out once a matched found. I thought a script that catches Packagizer rules return true then exit out. So, what is really happening behind the scene? Are all normal rules in Packagizer get executed first then finish up with this script? I'm not complaining, just trying to understand (: |
#1124
|
|||
|
|||
![]() Quote:
Quote:
It is better to rename the package after it is finished. Just use the rename method and append your custom string to it. Quote:
Code:
if(state == "BEFORE"){ //run this code before packagizer rules are applied } if(state = "AFTER"){ //run this code before packagizer rules are applied } Without the condition, the script will be executed twice. Once before packagizer rules are applied and once more after that. While the script can do a lot of things which the packagizer extension cannot, I use both. For simple tasks I use the extension and for features missing from the extension, I use a script. |
#1125
|
|||
|
|||
![]()
thanks again for the insight.
do you have the reference of all the jd functions glossary or is it documented? I looked up on wiki but couldn't find it. |
#1126
|
|||
|
|||
![]()
Click 'Show/Hide Help' in the script editor window main menu to list all the available methods. In some cases some context specific methods will be listed only after you have set/selected the event trigger for the script.
|
#1127
|
|||
|
|||
![]()
just learned I do have a blind spot!
|
#1128
|
|||
|
|||
![]() Quote:
Code:
var getDlSel = lgSelection.getDownloadLink.getName(); alert(getDlSel); //return error: ReferenceError: 'lgSelection' is not defined |
#1129
|
|||
|
|||
![]() Code:
// Linkgrabber context menu button pressed demo if (name == "LG context menu demo") { var myLinkgrabberSelection = lgSelection; var myCrawledLink = myLinkgrabberSelection.getContextLink(); if (myCrawledLink) alert(myCrawledLink.getName()); } |
#1130
|
|||
|
|||
![]() Code:
var myCrawledLink = myLinkgrabberSelection.getContextLink(); tried w/o luck: myCrawledLink.getName().execCommand("copy") ref: hxxps://www.w3schools.com/howto/howto_js_copy_clipboard.asp |
#1131
|
|||
|
|||
![]() Quote:
You can customize your context menu and add/configure "Copy Information" item and format the variables which you want to be copied to the clipboard when you click it. |
#1132
|
|||
|
|||
![]()
oh ok, that's too bad.
as far as debugging goes. alert() is the only other method other than writeFile() |
#1133
|
|||
|
|||
![]() Quote:
Code:
log(myObject[]);/*Log to stderr and to JDownloader Log Files*/ In lieu of console in eventscripter, you can load the log file or your custom file in notepad++ and enable its auto-update/scroll to end on update feature. |
#1134
|
|||
|
|||
![]()
thanks.
Why 'i' is global var in this scenario? Shouldn't 'i' is local in _getLists()? notice 'i' got overwrites each time it returns from func being called. Code:
//init var pkgs = getAllFilePackages(); var count = 0; for (i = 0; i < pkgs.length; i++) { var pkg = pkgs[i]; _getLists(pkg); count +=1; if (count > 5) break; } alert('pkg count:'+i+'/'+pkgs.length); //THIS i increment got reassigned to the i in _getLists() //function function _getLists(pkg) { var lists = pkg.getDownloadLinks(); var kount = 0; for (i = 0; i < lists.length; i++) { var list = lists[i]; kount +=1; if (kount > 2) break; } alert('list count:'+i+'/'+lists.length); } Last edited by zreenmkr; 29.02.2020 at 22:46. |
#1135
|
|||
|
|||
![]() Quote:
Nested functions have access to 'local' variables declared in their outer scope. So, in nested functions, it is better to use variable names which have not already been used in the outer scope. |
#1136
|
|||
|
|||
![]() Quote:
|
#1137
|
|||
|
|||
![]()
Is it a good common practice to use non-constant global var between functions instead of passing it?
|
#1138
|
|||
|
|||
![]() Quote:
|
#1139
|
|||
|
|||
![]()
Once you select a trigger, properties returned by that trigger will be listed at the bottom of the page and their corresponding methods will be listed separately further up on the same page.
|
#1140
|
|||
|
|||
![]()
got it.
Code:
// Get Selected packageName // Trigger : "DownloadList Contextmenu Button Pressed" if (name == "Get Selected packageName") { try { var selected = dlSelection.getContextLink(); var package = selected.getPackage(); if (selected) alert(selectedPackage + ': ' + package ); } catch (e) { alert('error: Right-Click on <fileName> & try again.'); } } Only able to get package name by right click on file name but can't seem to find a function that get package name on selected package. |
![]() |
Thread Tools | |
Display Modes | |
|
|