EasierSendToKindle

automatically download epub (or any) file and open email client

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         EasierSendToKindle
// @version      1.1
// @description  automatically download epub (or any) file and open email client
// @author       daydreamorama
// @include      /https?://archiveofourown\.org/.*works/\d+/
// @grant        none
// @namespace https://greasyfork.org/en/users/36620
// ==/UserScript==



(function () {
    // Change this to your email address that is your kindle
    var email = '[email protected]'

    // if you prefer other extensions change this. (such as 'mobi')
    var ext = 'epub'


    var chapter = document.getElementById('chapters');
    var btn = $('<input class="button" type="button" value="' + ext + '"></input> ');

    //const btn = document.createElement('button')
    //btn.innerText = ext

    var header_menu = $('ul.work.navigation.actions');
    header_menu.find('li.download').append(btn);

    const titleLink = document.querySelector('h2.title.heading');
    var title = titleLink.textContent.trim();
    var workId = (window.location.pathname.match(/\/works\/(\d+)\b/) || [])[1];
    var link = `https://archiveofourown.org/downloads/${workId}/${encodeURIComponent(title)}.${ext}?updated_at=${Date.now()}`

    // ideally we'd just take the link but lets hope your title doesn't have things like ? in it ...
//    btn.innerText = link
    btn.click(function() {
        window.open(link)
        window.open('mailto:' + email + '?subject=empty&body=empty')
    });
})();