// ==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 // @grant GM_addStyle // @version 1.0 // @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 // @icon https://www.xuexi.cn/favicon.ico // @downloadURL none // ==/UserScript== (function() { var ver = '1.0'; function addGMStyle() { GM_addStyle(` .modal-window {position: fixed;background-color: rgba(255, 255, 255, 0.25);top: 0;right: 0;bottom: 0;left: 0;z-index: 999;visibility: hidden;opacity: 0;pointer-events: none;transition: all 0.3s;} .modal-window-display {visibility: visible;opacity: 1;pointer-events: auto;} .modal-window > div {width: 400px;height:230px;position: absolute;top: 15%;left: 15%;-webkit-transform: translate(-50%, -50%);transform: translate(-50%, -50%);padding: 2em;background:#CFF4F9;} .modal-window header {font-weight: bold;} .modal-window h2 {color: #007722;font: 15px Arial, Helvetica, sans-serif;margin: 0 0 12px 0;line-height: 150%;} .modal-window h1 {font-size: 150%;margin: 0 0 15px;} .modal-close {color: #aaa;line-height: 50px;font-size: 100%;position: absolute;right: 0;text-align: center;top: 0;width: 70px;text-decoration: none;} .modal-close:hover {color: black;} .modal-window div:not(:last-of-type) {margin-bottom: 15px;} small {color: #aaa;} .buy {background-color: #F39300;} .buy-btn {display: inline-block;margin-right: 8px;padding: 5px 12px;border-radius: 2px;color: #fff;font-size: 13px;line-height: 1;text-align: center;box-shadow: 0 0 1px 0 rgb(0 0 0 / 7%);} `) } function tips(title,content,force=false){ //$btn = ''; addGMStyle(); $html = ''; $('body').append($html); key = md5(content); if(force == false){ if(getStorage(key) != 'ok'){ $('#tips').addClass('modal-window-display'); } }else{ $('#tips').addClass('modal-window-display'); } 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', '.modal-close', function() { $('#tips').removeClass('modal-window-display'); }); $(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('无响应'); } } }); }); })();