// ==UserScript== // @name 找学习资料大师[电子书搜索神器]支持豆瓣/鸠摩搜书 // @namespace ilovexuexi // @match *://www.jiumodiary.com/* // @match *://m.douban.com/book/subject/* // @match *://book.douban.com/subject/* // @match *://www.forkdoc.com/Center/prev.asp // @grant GM_xmlhttpRequest // @connect * // @connect *://*.886889.xyz // @version 1.6 // @author - // @description 帮你找到你想要的学习资料,搜索到绝大部分的电子书,支持豆瓣电脑端/手机端,支持鸠摩搜书扩展搜索结果 // @require https://cdn.staticfile.org/jquery/1.10.0/jquery.js // @require https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js // @require https://cdn.jsdelivr.net/npm/sweetalert2@10.10.0/dist/sweetalert2.all.min.js // @icon https://www.xuexi.cn/favicon.ico // @downloadURL https://update.greasyfork.icu/scripts/423587/%E6%89%BE%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99%E5%A4%A7%E5%B8%88%5B%E7%94%B5%E5%AD%90%E4%B9%A6%E6%90%9C%E7%B4%A2%E7%A5%9E%E5%99%A8%5D%E6%94%AF%E6%8C%81%E8%B1%86%E7%93%A3%E9%B8%A0%E6%91%A9%E6%90%9C%E4%B9%A6.user.js // @updateURL https://update.greasyfork.icu/scripts/423587/%E6%89%BE%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99%E5%A4%A7%E5%B8%88%5B%E7%94%B5%E5%AD%90%E4%B9%A6%E6%90%9C%E7%B4%A2%E7%A5%9E%E5%99%A8%5D%E6%94%AF%E6%8C%81%E8%B1%86%E7%93%A3%E9%B8%A0%E6%91%A9%E6%90%9C%E4%B9%A6.meta.js // ==/UserScript== (function() { var ver = '1.6'; function tips(title,content,force=false){ key = md5(content+ver); if(force == false){ if(getStorage(key) != 'ok'){ Swal.fire({ title: title, width:'800px', html: content, allowOutsideClick:false, confirmButtonText: '关闭' }); } }else{ Swal.fire({ title: title, width:'800px', html: content, allowOutsideClick:false, confirmButtonText: '关闭' }); } setStorage(key, 'ok'); } function getStorage(key) { return localStorage.getItem(key) } function setStorage(key, value) { return localStorage.setItem(key, value) } function get_book_id(url) { let re = /\/subject\/(\d+)/g; let matches = re.exec(url); if (matches && matches.length > 1) { return parseInt(matches[1]); } } function getExt(fileName) { var fileExtension = fileName.split('.').pop().toUpperCase(); return fileExtension; } function formatBytes($size) { $units = new Array(' B', ' KB', ' MB', ' GB', ' TB'); for ($i = 0; $size >= 1024 && $i < 4; $i++) { $size /= 1024; } return $size.toFixed(2) + $units[$i]; } function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; } $(document).on('click', '#addnew', function() { url = "https://ops.886889.xyz/addnew.php?ver=" + ver; //console.log($("#addnewform").serialize()); GM_xmlhttpRequest({ method: "POST", url: url, data :$("#addnewform").serialize(), headers: { "Referer": "https://www.baidu.com/" }, onload: function(res) { console.log($("#addnewform").serialize()); if (res.status == 200) { $res = $.parseJSON(res.response); console.log($res); if($res.status == 'success'){ $('[name="md5"]').val(''); //$('[name="name"]').val(''); $('[name="ext"]').val(''); } alert($res.msg); } else { alert('无响应'); } } }); }); var urlstr = decodeURI(location.href); n = urlstr.search("//www.forkdoc.com/Center/prev.asp"); if(n !== -1){ $result = $.parseJSON($('body').html()); if($result.type == 200){ if(confirm('转存成功需要跳转到你的主页查看吗?')){ window.location.href= "//www.forkdoc.com/Center/ownfiles.asp"; } }else{ alert('啊哦,转存失败了,自己看看错误代码吧,如果是未登录请重新登录后重试') } }else{ GM_xmlhttpRequest({ method: "POST", url: 'https://ops.886889.xyz/tips.php?ver='+ver, data :$("#addnewform").serialize(), headers: { "Referer": "https://www.baidu.com/" }, onload: function(res) { if (res.status == 200) { $res = $.parseJSON(res.response); if($res.ver > ver){ $message = '不能使用的版本,正在使用的版本为'+ver+',已发布的最新版本为'+$res.ver+'。请尽快升级到最新版本。点击确定或取消均会跳转至最新的下载页面'; if(confirm($message)){ window.location.href=$res.update_url; }else{ window.location.href=$res.update_url; } return false; } //console.log($res); if($res.status == 'success'){ n = urlstr.search("//m.douban.com/book/subject/"); if(n !== -1){ $template = '
'+ '
'+ '' + $res.msg + ''+ ''+ '
'+ '
'; $('#subject-rating-root').after($template); }else{ tips($res.title,$res.msg,$res.force); } if($res.share == true){ $('#share_tips').css('display','block'); $('#addnewform').css('display','block'); } } } else { console.log('无响应'); } } }); } ///手机版 n = urlstr.search("//m.douban.com/book/subject/"); if(n !== -1){ id = get_book_id(urlstr); //console.log(id) $('#tips').remove(); if (id != undefined) { // $name = $.trim($(".sub-detail").find('.sub-title').text()); // var $insertHtml = // '
' + // '
' + // '

在哪儿下载这本书 · · · · · ·

' + // ''+ // ''+ // '' + // '
' + // '
'; // $("#subject-rating-root").before($insertHtml); $('.vendors-link-group').before('

加载中……

'); url = "https://ops.886889.xyz/db.php?ver=" + ver + "&id=" + id; GM_xmlhttpRequest({ method: "GET", url: url, headers: { "Referer": "https://www.baidu.com/" }, onload: function(res) { console.log(res); $('#load').html(''); if (res.status == 200) { $res = $.parseJSON(res.response); $search = $res.info; if ($res.status == 'error') { $('.vendors-link-group').before('

没有结果

'); return; } $.each($search, function(i, item) { $form = '
' + '' + '' + '' + '
'; $template = '
'+ '
'+ '' + item['name'] + ''+ '转存('+formatBytes(item['size']) +')'+ '
'+ '
'; // $template = '
  • ' + // '
    ' + // '' + // '' + // '
    ' + // '
  • '; $('.vendors-link-group').before($template + $form); }); } else { alert('无响应'); } } }); } } n = urlstr.search("//book.douban.com/subject/"); if(n !== -1){ id = get_book_id(urlstr); //console.log(id) $('#dale_book_subject_top_right').remove(); if (id != undefined) { $name = $("[property='v:itemreviewed']").text()+'-'+$.trim($('#info .pl:contains(作者)').next().text()); var $insertHtml = '
    ' + '
    ' + '

    在哪儿下载这本书 · · · · · ·

    ' + ''+ ''+ '' + '
    ' + '
    '; $("#buyinfo").before($insertHtml); $('#downlist').append('

    加载中……

    '); url = "https://ops.886889.xyz/db.php?ver=" + ver + "&id=" + id; GM_xmlhttpRequest({ method: "GET", url: url, headers: { "Referer": "https://www.baidu.com/" }, onload: function(res) { $('#downlist').html(''); if (res.status == 200) { $res = $.parseJSON(res.response); $search = $res.info; if ($res.status == 'error') { $('#downlist').append('

    没有结果

    '); return; } $.each($search, function(i, item) { $form = '
    ' + '' + '' + '' + '
    '; $template = '
  • ' + '
    ' + '' + '' + '
    ' + '
  • '; $('#downlist').append($template + $form); }); } else { alert('无响应'); } } }); } } ///////////////////////jiumo $(document).on('click', '#SearchButton', function() { SearchWord = $('#SearchWord').val(); url = "https://ops.886889.xyz/search.php?ver=" + ver + "&wd=" + SearchWord; GM_xmlhttpRequest({ method: "GET", url: url, headers: { "Referer": "https://www.baidu.com/" }, onload: function(res) { if (res.status == 200) { $res = $.parseJSON(res.response); $search = $res.info; //console.log($res) timer = setInterval(function() { if ($('#result-ul').find('.span-host').length >= 1) { if ($res.status == 'error') { $('#result-ul div:eq(0)').before('

    没有结果

    '); if ($('.zhuancun').length > 0) { clearInterval(timer); } return; } $.each($search, function(i, item) { $form = '
    ' + '' + '' + '' + '
    '; $html = '
    ' + '' + '' + item['name'] + '' + '' + '
    ' + '
    分享时间: ' + getNowFormatDate() + ', 文件大小: ' + formatBytes(item['size']) + '
    ' + '
    ForkDoc' + '' + '转存' + '' + '
    '; $('#result-ul div:eq(0)').before($html + $form); $ext = getExt(item['name']); $dom = $('#' + $ext); if ($dom.length == 1) { $count_text = $dom.text(); $strs = $count_text.split("(")[1]; $format_num = $strs.replace(')', ' '); $format_num = parseInt($format_num) + 1; $dom.text($ext + '(' + $format_num + ')') } }); if ($('.zhuancun').length > 0) { clearInterval(timer); } } else { //console.log('不再执行'); //clearInterval(timer); } }, 2000); } else { alert('无响应'); } } }); }); })();