archiveOrgAssistant

download books from archive.org

2023-02-23 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         archiveOrgAssistant
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  download books from archive.org 
// @author       [email protected]
// @match        https://archive.org/details/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=archive.org
// @run-at       document-idle
// @grant        GM_registerMenuCommand
// @license      MIT
// ==/UserScript==

function getConfig(bookid){
    let ele = document.createElement('a');
    let cookies = document.cookie.split('; ');
    let regxp =new RegExp('^(logged-in-user|donation-identifier|logged-in-sig|PHPSESSID|loan-'+bookid+')','i');
    let conf = [
        "Please don't change this file manually, it's important",
        "get the downloader from https://github.com/mooring/archive.org.book.downloader",
        "then following the constructions",
        "============================================================================",
    ];
    let proxy = '';
    cookies.forEach(i=>{
        if(regxp.test(i)){
            conf.push(i.replace(/(logged-in-|-identifier)/i,'').replace('-'+bookid,''));
        }
    });
    if(!/\/details\/\w+/i.test(location.pathname)){
        alert("Working on book loan page only");
        return;
    }
    let img = document.querySelector('.BRpagecontainer .BRpageimage');
    if(!img){
        alert("Please fresh page and try again");
        return;
    }
    let url = new URL(img.src);
    let zipm = url.search.match(/=\/(\d+)\/items\//);
    if(url.search.indexOf('&server='+url.hostname) != -1){
        alert("Please borrow the book first!");
        return;
    }
    proxy = prompt("Input proxy string like http://127.0.0.1:8899, if no proxy keep it empty");
    conf.push('authority='+url.hostname);
    conf.push('path='+location.pathname);
    conf.push('bookid='+bookid);
    conf.push('zipnum='+(zipm?zipm[1]:'29'));
    conf.push('proxy='+(proxy?proxy.replace(/[\r\n\t\s]+/g,''): ''));
    conf.push("=========================================================");
    conf.push("version: 0.1");
    conf.push("author : https://codernote.club");
    ele.style.display = 'none';
    ele.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(conf.join('\n')));
    ele.setAttribute('download', 'config.conf');
    document.body.appendChild(ele);
    ele.click();
    document.body.removeChild(ele);
}

(function() {
    'use strict';
    let bookid = location.pathname.split('/details/')[1].split('/')[0];
    GM_registerMenuCommand("get Configuration", function(evt, keybord){
        let cookie = document.cookie;
        if(/logged-in-sig=[^;]+/.test(cookie) && /logged-in-user=[^;]+/.test(cookie)){
            getConfig(bookid);
        }
    });
    GM_registerMenuCommand("get Downloader", function(evt, keybord){
        window.open('https://github.com/mooring/archive.org.book.downloader');
    });
})();