View Single Post
  #133  
Old 10.12.2020, 12:28
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,125
Default

Replacement scripts

Script #1
Code:
/*
    Move selected links from linkgrabber list to history file
    Trigger required: Linkgrabber Contextmenu Button Pressed
    Customize linkgrabber context menu > Add new "Eventscripter Trigger" button > Rename it to "Move to history" (without quotes) > Change Icon (optional)
*/

if (name = "Move to history") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name,true) || file.exists() && readFile(file) || "";
    var unique = "";

    lgSelection.getLinks().forEach(function(link) {
        if (link.availableState == "ONLINE") {
            var url = link.contentURL || link.pluginURL;

            if (urls.indexOf(url) == -1) {
                unique += url + "\r\n";
            }

            link.remove();
        }
    })

    if (unique) {
        writeFile(file, unique + "\r\n", true);
    }
    
    setProperty(file.name, urls += unique, true);
    lock.writeUnlock();
}

Script #2
Code:
/*
    Move selected links from download list to history file / Disable corresponding links in linkgrabber list
    Trigger required: Downloadlist Contextmenu Button Pressed
    Customize linkgrabber context menu > Add new "Eventscripter Trigger" button > Rename it to "Move to history" (without quotes) > Change Icon (optional)
*/

if (name = "Move to history") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name, true) || file.exists() && readFile(file) || "";
    var unique = "";

    dlSelection.getLinks().forEach(function(link) {
        if (link.finished) {
            var url = link.contentURL || link.pluginURL;

            if (urls.indexOf(url) == -1) {
                unique += url + "\r\n";
            }

            link.remove();
        }
    })

    if (unique) {
        writeFile(file, unique + "\r\n", true);
    }

    setProperty(file.name, urls += unique, true);

    lock.writeUnlock();

    getAllCrawledLinks().forEach(function(link) {
        if (link.availableState == "ONLINE") {
            var url = link.contentURL || link.pluginURL;

            if (link.host == "youtube.com") {
                url = link.containerURL;
            }

            if (urls.indexOf(url) > -1) {
                var text = "#duplicatelink";
                var comment = link.comment;

                if (comment) {
                    text = text + " " + comment;
                }

                link.comment = text;
                link.enabled = false;
            }
        }
    });
}

Script #3
Code:
/* 
    Disable duplicate link in Lingrabber list
    Trigger required: A new link has been added
*/

var link = crawledLink;

if (link.availableState == "ONLINE") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name, true);

    if (urls == null) {
        urls = file.exists() && readFile(file) || "";
        setProperty(file.name, urls, true);
    }

    lock.writeUnlock();

    if (urls) {
        var url = link.contentURL || link.pluginURL;

        if (link.host == "youtube.com") {
            url = link.containerURL;
        }

        if (urls.indexOf(url) > -1) {
            var text = "#duplicatelink";
            var comment = link.comment;

            if (comment) {
                text = text + " " + comment;
            }

            link.comment = text;
            link.enabled = false;
        }
    }
}

Last edited by mgpai; 10.12.2020 at 15:38. Reason: Modified all 3 scripts.
Reply With Quote