Greasy Fork is available in English.

豆瓣读书助手

为豆瓣读书页面添加亚马逊Kindle、微信读书、多看阅读、喜马拉雅等链接

// ==UserScript==
// @name         eBooks Assistant
// @name:zh-CN   豆瓣读书助手
// @namespace    https://github.com/caspartse/eBooksAssistant
// @version      0.12.0
// @description  eBooks Assistant for douban.com
// @description:zh-CN 为豆瓣读书页面添加亚马逊Kindle、微信读书、多看阅读、喜马拉雅等链接
// @author       Caspar Tse
// @license      MIT License
// @supportURL   https://github.com/caspartse/eBooksAssistant
// @match        https://book.douban.com/subject/*
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @connect      amazon.cn
// @connect      duokan.com
// @connect      8.210.234.3
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function() {
    var version = "0.12.0";
    var domain = "http://8.210.234.3:8081";

    function changeMargin() {
        if ($('[data-ebassistant="read"]').height() > 36) {
            $('[data-ebassistant="read"]').attr("style", "margin-right:0;");
        }
    }

    function queryAmazon1(isbn, title, token="") {
        GM_xmlhttpRequest({
            method: "GET",
            url: "https://www.amazon.cn/s?__mk_zh_CN=亚马逊网站&i=digital-text&k=" + isbn + "&ref=nb_sb_noss&url=search-alias%3Ddigital-text",
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var doc = responseDetail.responseText;
                var errorFlag = /("totalResultCount"\:0)|(在Kindle商店中未找到)|(Kindle商店中没有)/gi.exec(doc);
                if (!errorFlag) {
                    var regexAmazonUrl = /href="(\S+keywords=\d+[^"]+)"/gi;
                    var amazonUrl = "https://www.amazon.cn" + regexAmazonUrl.exec(doc)[1];
                    amazonUrl = amazonUrl.replace(isbn, title);
                    var partnerTemplate = "";
                    if ($('.online-type[data-ebassistant="read"]').length) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div>';
                        $('.online-type[data-ebassistant="read"]').append(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    } else if ($('.online-type[data-ebassistant="audio"]').length) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="audio"]').before(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    }
                    var regexAmazonPrice = /<span class="a-offscreen">[¥|¥]([0-9\.]+)<\/span>/gi;
                    var amazonPrice = regexAmazonPrice.exec(doc)[1];
                    var amazonKu = false;
                    var buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span><img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" style="border-radius: 50%; box-shadow: 0 0 1px 0 rgba(0,0,0,0.6);" width="16" height="16" border="0">&nbsp;Kindle</span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> </li>';
                    if (amazonPrice == 0.00 ) {
                        buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span > <img alt="Kindle Unlimited" src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_ku.png" width="75" height="10" border="0"> </span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> <div class="more-info"> <span class="buyinfo-promotion">KU可免费借阅</span> </div> </li>';
                        regexAmazonPrice = /<span dir="auto">或者[¥|¥]([0-9\.]+)购买<\/span>/gi;
                        amazonPrice = regexAmazonPrice.exec(doc)[1];
                        amazonKu = true;
                    }
                    buyItemTemplate = buyItemTemplate.replaceAll("{templateUrl}", amazonUrl);
                    buyItemTemplate = buyItemTemplate.replace("{templatePrice}", amazonPrice);
                    $("#buyinfo ul:nth-child(2)").prepend(buyItemTemplate);
                    var amazonShortUrl = /(https:\/\/www\.amazon\.cn\/dp\/[0-9a-zA-Z]+\/)/gi.exec(amazonUrl)[1];
                    GM_xmlhttpRequest({
                        method: "POST",
                        url: domain + "/amazon/update",
                        data: "isbn=" + isbn + "&price=" + amazonPrice + "&url=" + amazonShortUrl + "&ku=" + amazonKu + "&token=" + token + "&version=" + version,
                        headers: {
                            "Content-Type": "application/x-www-form-urlencoded"
                        }
                    });
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    function queryAmazon2(isbn, title, subtitle, author, translator, publisher) {
        GM_xmlhttpRequest({
            method: "GET",
            url: domain + "/amazon?isbn=" + isbn + "&title=" + title + "&subtitle=" + subtitle + "&author=" + author + "&translator=" + translator + "&publisher=" + publisher + "&version=" + version,
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var result = JSON.parse(responseDetail.responseText);
                console.log(result);
                var token = result.token;
                if (result.errmsg == "") {
                    var amazonUrl = result.data.url;
                    var amazonPrice = result.data.price;
                    var ku = result.data.ku;
                    var partnerTemplate = "";
                    if ($('.online-type[data-ebassistant="read"]').length) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div>';
                        $('.online-type[data-ebassistant="read"]').append(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    } else if ($('.online-type[data-ebassistant="audio"]').length) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="audio"]').before(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" width="16" height="16"> <span>Kindle</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", amazonUrl));
                    }
                    var buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span><img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_kindle.png" style="border-radius: 50%; box-shadow: 0 0 1px 0 rgba(0,0,0,0.6);" width="16" height="16" border="0">&nbsp;Kindle</span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> </li>';
                    if (ku === true) {
                        buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span > <img alt="Kindle Unlimited" src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_ku.png" width="75" height="10" border="0"> </span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> <div class="more-info"> <span class="buyinfo-promotion">KU可免费借阅</span> </div> </li>';
                    }
                    buyItemTemplate = buyItemTemplate.replaceAll("{templateUrl}", amazonUrl);
                    buyItemTemplate = buyItemTemplate.replace("{templatePrice}", amazonPrice);
                    $("#buyinfo ul:nth-child(2)").prepend(buyItemTemplate);
                } else {
                    console.log("call queryAmazon1.");
                    queryAmazon1(isbn, title, token);
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    function queryXimalaya(isbn, title, subtitle, author, translator, publisher) {
        GM_xmlhttpRequest({
            method: "GET",
            url: domain + "/ximalaya?isbn=" + isbn + "&title=" + title + "&subtitle=" + subtitle + "&author=" + author + "&translator=" + translator + "&publisher=" + publisher + "&version=" + version,
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var result = JSON.parse(responseDetail.responseText);
                console.log(result);
                if (result.errmsg == "") {
                    var ximalayaUrl = result.data.url;
                    var partnerTemplate = "";
                    if ($(".online-partner .online-type").length == 2) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_ximalaya.png" width="16" height="16"> <span>喜马拉雅</span> </a> </div>';
                        $('.online-type[data-ebassistant="audio"]').append(partnerTemplate.replace("{templateUrl}", ximalayaUrl));
                    } else if ($(".online-partner .online-type").length == 1) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="audio"> <span>在线试听:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_ximalaya.png" width="16" height="16"> <span>喜马拉雅</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="read"]').after(partnerTemplate.replace("{templateUrl}", ximalayaUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="audio"> <span>在线试听:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_ximalaya.png" width="16" height="16"> <span>喜马拉雅</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", ximalayaUrl));
                    }
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    function queryDuokan1(isbn, token="") {
        GM_xmlhttpRequest({
            method: "GET",
            url: "http://www.duokan.com/search/" + isbn + "/1",
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var doc = responseDetail.responseText;
                var errorFlag = /<textarea name="json" id="book_list">(\s*\[\s*\]\s*)<\/textarea>/gi.exec(doc);
                if (!errorFlag) {
                    var items = /<textarea name="json" id="book_list">([\s\S]+?)<\/textarea>/gi.exec(doc);
                    var regexDuokanUrl = /url : \'(\/book\/\d+)\'/gi;
                    var duokanUrl = "http://www.duokan.com" + regexDuokanUrl.exec(items)[1];
                    var partnerTemplate = "";
                    if ($('.online-type[data-ebassistant="read"]').length) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div>';
                        $('.online-type[data-ebassistant="read"]').append(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else if ($('.online-type[data-ebassistant="audio"]').length) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="audio"]').before(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    }
                    var regexDuokanPrice = /price : \'([0-9\.]+)\'/gi;
                    var duokanPrice = regexDuokanPrice.exec(items)[1];
                    var buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span><img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" style="border-radius: 50%; box-shadow: 0 0 1px 0 rgba(0,0,0,0.6);" width="16" height="16" border="0">&nbsp;多看阅读</span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> </li>';
                    buyItemTemplate = buyItemTemplate.replaceAll("{templateUrl}", duokanUrl);
                    buyItemTemplate = buyItemTemplate.replace("{templatePrice}", duokanPrice);
                    $("#buyinfo ul:nth-child(2)").prepend(buyItemTemplate);
                    GM_xmlhttpRequest({
                        method: "POST",
                        url: domain + "/duokan/update",
                        data: "isbn=" + isbn + "&price=" + duokanPrice + "&url=" + duokanUrl + "&token=" + token + "&version=" + version,
                        headers: {
                            "Content-Type": "application/x-www-form-urlencoded"
                        }
                    });
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    function queryDuokan2(isbn, title, subtitle, author, translator, publisher) {
        GM_xmlhttpRequest({
            method: "GET",
            url: domain + "/duokan?isbn=" + isbn + "&title=" + title + "&subtitle=" + subtitle + "&author=" + author + "&translator=" + translator + "&publisher=" + publisher + "&version=" + version,
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var result = JSON.parse(responseDetail.responseText);
                console.log(result);
                var token = result.token;
                if (result.errmsg == "") {
                    var duokanUrl = result.data.url;
                    var duokanPrice = result.data.price;
                    var partnerTemplate = "";
                    if ($('.online-type[data-ebassistant="read"]').length) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div>';
                        $('.online-type[data-ebassistant="read"]').append(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else if ($('.online-type[data-ebassistant="audio"]').length) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="audio"]').before(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" width="16" height="16"> <span>多看阅读</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    }
                    var buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span><img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_duokan.png" style="border-radius: 50%; box-shadow: 0 0 1px 0 rgba(0,0,0,0.6);" width="16" height="16" border="0">&nbsp;多看阅读</span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> </li>';
                    buyItemTemplate = buyItemTemplate.replaceAll("{templateUrl}", duokanUrl);
                    buyItemTemplate = buyItemTemplate.replace("{templatePrice}", duokanPrice);
                    $("#buyinfo ul:nth-child(2)").prepend(buyItemTemplate);
                } else {
                    console.log("call queryDuokan1.");
                    queryDuokan1(isbn, token);
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    function queryWeread(isbn, title, subtitle, author, translator, publisher) {
        GM_xmlhttpRequest({
            method: "GET",
            url: domain + "/weread?isbn=" + isbn + "&title=" + title + "&subtitle=" + subtitle + "&author=" + author + "&translator=" + translator + "&publisher=" + publisher + "&version=" + version,
            headers: {
                "User-agent": window.navigator.userAgent,
            },
            onload: function(responseDetail) {
                var result = JSON.parse(responseDetail.responseText);
                console.log(result);
                if (result.errmsg == "") {
                    var duokanUrl = result.data.url;
                    var duokanPrice = result.data.price;
                    var partnerTemplate = "";
                    if ($('.online-type[data-ebassistant="read"]').length) {
                        partnerTemplate = '<div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_weread.png" width="16" height="16"> <span>微信读书</span> </a> </div>';
                        $('.online-type[data-ebassistant="read"]').append(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else if ($('.online-type[data-ebassistant="audio"]').length) {
                        partnerTemplate = '<div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_weread.png" width="16" height="16"> <span>微信读书</span> </a> </div></div>';
                        $('.online-type[data-ebassistant="audio"]').before(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    } else {
                        partnerTemplate = '<div class="online-partner"> <div class="online-type" data-ebassistant="read"> <span>在线试读:</span> <div class="online-read-or-audio"> <a class="impression_track_mod_buyinfo" target="_blank" href="{templateUrl}" one-link-mark="yes"> <img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_weread.png" width="16" height="16"> <span>微信读书</span> </a> </div></div> </div>';
                        $("#link-report").after(partnerTemplate.replace("{templateUrl}", duokanUrl));
                    }
                    var buyItemTemplate = '<li> <div class="cell price-btn-wrapper"> <div class="vendor-name"> <a target="_blank" href="{templateUrl}"> <span><img src="https://ebooks-assistant.oss-cn-guangzhou.aliyuncs.com/icon_weread.png" style="border-radius: 50%; box-shadow: 0 0 1px 0 rgba(0,0,0,0.6);" width="16" height="16" border="0">&nbsp;微信读书</span> </a> </div> <div class="cell impression_track_mod_buyinfo"> <div class="cell price-wrapper"> <a target="_blank" href="{templateUrl}"> <span class="buylink-price "> {templatePrice}元 </span> </a> </div> <div class="cell"> <a target="_blank" href="{templateUrl}" class="buy-book-btn e-book-btn"> <span>购买电子书</span> </a> </div> </div> </div> </li>';
                    buyItemTemplate = buyItemTemplate.replaceAll("{templateUrl}", duokanUrl);
                    buyItemTemplate = buyItemTemplate.replace("{templatePrice}", duokanPrice);
                    $("#buyinfo ul:nth-child(2)").prepend(buyItemTemplate);
                }
                return;
            }
        });
        changeMargin();
        return;
    }

    try {
        $(".online-partner .online-type:nth-child(1)").attr("data-ebassistant", "read");
        $(".online-partner .online-type:nth-child(2)").attr("data-ebassistant", "audio");
    } catch(e) {
        console.log(e);
    }
    var newStyle = `<style type="text/css" media="screen">.online-partner{flex-wrap:wrap;padding-top:5px;padding-bottom:5px}.online-type{flex-wrap:wrap}.online-read-or-audio{margin-top:5px;margin-bottom:5px}.online-partner .online-type:nth-child(1){margin-right:20px}.online-partner .online-type:last-child{margin-right:0}.online-partner .online-type:nth-child(2){padding-left:0}[data-ebassistant=read] div:last-child a{margin-right:0}</style>`;
    $("#content").append(newStyle);

    var regexLinkedData = /<script type="application\/ld\+json">([\s\S]+?)<\/script>/gi;
    var linkedData = regexLinkedData.exec(document.documentElement.innerHTML)[1].trim();
    linkedData = JSON.parse(linkedData);
    console.log(linkedData);
    var isbn = linkedData.isbn;
    console.log(isbn);
    var title = linkedData.name;
    console.log(title);
    var subtitle = "";
    try {
        var regexSubtitle = /<span class="pl">\s*副标题:?<\/span>\s*:?\s*([\s\S]+?)<br\/?>/gi;
        subtitle = regexSubtitle.exec(document.documentElement.innerHTML.replace(/&nbsp;/gi, " "))[1].trim();
    } catch(e) {
        console.log(e);
    }
    console.log(subtitle);
    var authorStr = "";
    for (var i=0, j=linkedData.author.length; i<j; i++) {
        authorStr += linkedData.author[i].name + " " ;
    }
    var author = authorStr;
    console.log(author);
    var translator = "";
    try {
        var regexTranslator = /<span class="pl">\s*译者:?<\/span>\s*:?\s*<a[^>]+>([\s\S]+?)<\/a>/gi;
        translator = regexTranslator.exec(document.documentElement.innerHTML.replace(/&nbsp;/gi, " "))[1].trim();
    } catch(e) {
        console.log(e);
    }
    console.log(translator);
    var regexPublisher = /<span class="pl">\s*出版社:?<\/span>\s*:?\s*([\s\S]+?)<br\/?>/gi;
    var publisher = regexPublisher.exec(document.documentElement.innerHTML.replace(/&nbsp;/gi, " "))[1].trim();
    console.log(publisher);

    queryWeread(isbn, title, subtitle, author, translator, publisher);
    queryAmazon2(isbn, title, subtitle, author, translator, publisher);
    queryDuokan2(isbn, title, subtitle, author, translator, publisher);
    queryXimalaya(isbn, title, subtitle, author, translator, publisher);

    return;
})();