├── LICENSE ├── README.md ├── README_zh.md ├── images ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg └── 8.jpg └── wenkudl ├── imgs ├── logo128.png ├── logo16.png ├── logo48.png └── logo64.png ├── index.html ├── js ├── getData.js └── index.js └── manifest.json /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 leechaojiang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wenkudl 2 | 3 | [![star this repo](http://githubbadges.com/star.svg?user=usecodelee&repo=wenku-download&style=default)](https://github.com/usecodelee/wenku-download) 4 | [![fork this repo](http://githubbadges.com/fork.svg?user=usecodelee&repo=wenku-download&style=default)](https://github.com/usecodelee/wenku-download/fork) ![](https://img.shields.io/badge/wenkudl-v1.0-green.svg) ![](https://img.shields.io/badge/language-javascript-yellow.svg) ![](https://img.shields.io/badge/use-extension-orange.svg) ![](https://img.shields.io/badge/javascript-90.0%25-lightgrey.svg) ![](https://img.shields.io/badge/licence-MIT-blue.svg) 5 | 6 | [中文 文档](https://github.com/usecodelee/wenku-download/blob/master/README_zh.md) 7 | 8 | Copy the baidu wenku Word or PDF article with one key, automatically save it as Word document, and download it to local. 9 | 10 | ## How To Use 11 | 12 | - **Dowmload** 13 | 14 | ```bash 15 | git clone https://github.com/usecodelee/wenku-download.git 16 | ``` 17 | 18 | - **Install** 19 | 20 | 1. > **Open the Google browser** 21 | 22 | 2. > **Click the Settings in the upper right corner --> more tools --> extension program** 23 | 24 | 25 | 26 | 3. > **Click on the top right corner to open developer mode** 27 | 28 | 29 | 30 | 4. > **Open the downloaded file and drag the wenkudl folder into the Google browser extender page** 31 | 32 | 33 | 34 | 5. > **installation success** 35 | 36 | 37 | 38 | - **Usage** 39 | 40 | 1. > **Open baidu library and find Word or PDF to download** 41 | 42 | 2. > **Slide down to the bottom and click "what's left?Page not read, continue to read "** 43 | 44 | 45 | 46 | 3. > **Click the wenkudl icon in the upper right corner** 47 | 48 | 49 | 50 | 4. > **Click start** 51 | 52 | 53 | 54 | 5. > **Just wait a moment** 55 | 56 | 57 | -------------------------------------------------------------------------------- /README_zh.md: -------------------------------------------------------------------------------- 1 | # wenkudl 2 | 3 | [![star this repo](http://githubbadges.com/star.svg?user=usecodelee&repo=wenku-download&style=default)](https://github.com/usecodelee/wenku-download) 4 | [![fork this repo](http://githubbadges.com/fork.svg?user=usecodelee&repo=wenku-download&style=default)](https://github.com/usecodelee/wenku-download/fork) ![](https://img.shields.io/badge/wenkudl-v1.0-green.svg) ![](https://img.shields.io/badge/language-javascript-yellow.svg) ![](https://img.shields.io/badge/use-extension-orange.svg) ![](https://img.shields.io/badge/javascript-90.0%25-lightgrey.svg) ![](https://img.shields.io/badge/licence-MIT-blue.svg) 5 | 6 | 一键复制文库Word或PDF文章,自动保存为Word文档并下载。 7 | 8 | ## 如何使用 9 | 10 | - **下载** 11 | 12 | ```bash 13 | git clone https://github.com/usecodelee/wenku-download.git 14 | ``` 15 | 16 | - **安装** 17 | 18 | 1. > **打开谷歌浏览器** 19 | 20 | 2. > **点击右上角的设置->更多工具->扩展程序** 21 | 22 | 23 | 24 | 3. > **点击右上角打开开发者模式** 25 | 26 | 27 | 28 | 4. > **打开下载的文件,将wenkudl文件夹拖入谷歌浏览器扩展程序页面** 29 | 30 | 31 | 32 | 5. > **安装成功** 33 | 34 | 35 | 36 | - **使用** 37 | 38 | 1. > **打开baidu文库,找到需要下载的Word或者PDF** 39 | 40 | 2. > **滑动到底部点击“还剩?页未读,继续阅读”按钮** 41 | 42 | 43 | 44 | 3. > **点击右上角的wenkudl图标** 45 | 46 | 47 | 48 | 4. > **点击start** 49 | 50 | 51 | 52 | 5. > **稍等片刻即可完成** 53 | 54 | 55 | -------------------------------------------------------------------------------- /images/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/1.jpg -------------------------------------------------------------------------------- /images/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/2.jpg -------------------------------------------------------------------------------- /images/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/3.jpg -------------------------------------------------------------------------------- /images/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/4.jpg -------------------------------------------------------------------------------- /images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/5.jpg -------------------------------------------------------------------------------- /images/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/6.jpg -------------------------------------------------------------------------------- /images/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/7.jpg -------------------------------------------------------------------------------- /images/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/images/8.jpg -------------------------------------------------------------------------------- /wenkudl/imgs/logo128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/wenkudl/imgs/logo128.png -------------------------------------------------------------------------------- /wenkudl/imgs/logo16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/wenkudl/imgs/logo16.png -------------------------------------------------------------------------------- /wenkudl/imgs/logo48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/wenkudl/imgs/logo48.png -------------------------------------------------------------------------------- /wenkudl/imgs/logo64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/usecodelee/wenku-download/f06ef91a0ee4c585f9e88e36a7bc20b347592e75/wenkudl/imgs/logo64.png -------------------------------------------------------------------------------- /wenkudl/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /wenkudl/js/getData.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | let url1 = window.location.href; 3 | let reg = /wenku.baidu.com\/view\//; 4 | if (reg.test(url1)) { 5 | let countDom = document.getElementsByClassName('page-count')[0]; 6 | let count = countDom.innerHTML.replace(/\//, ''); 7 | let result = ''; 8 | //获取到10页 9 | document.documentElement.scrollTop = 0; 10 | getPageContent(1); 11 | //获取页面内容 12 | function getPageContent(index) { 13 | setTimeout(() => { 14 | //解析其中的内容 15 | let id = 'pageNo-' + index; 16 | let byiddom = document.getElementById(id); 17 | let ele_p = byiddom.getElementsByTagName('p'); 18 | for (let i = 0; i < ele_p.length; i++) { 19 | let flag = addlf(ele_p[i]); 20 | if (flag == 1) {} else if (flag == 2) { 21 | result += '\n'; 22 | } else if (flag == 3) { 23 | result += ele_p[i].innerHTML + '\n'; 24 | } 25 | // 换行 26 | else if (flag == 1) { 27 | result += ele_p[i].innerHTML; 28 | } 29 | } 30 | //解析完毕以后:滚动 31 | document.documentElement.scrollTop = (index - 1) * 1500; 32 | //第二页跳转 33 | layer(index, count); 34 | if (index < count) { 35 | getPageContent(index + 1); 36 | } else { //全部解析完毕,下载 37 | // return; 38 | let fileName = Date.now() + ".doc"; 39 | var blob = new Blob(["\uFEFF" + result], { type: "text/doc;" }); 40 | var downloadLink = document.createElement("a"); 41 | if ("download" in downloadLink) { 42 | var url = URL.createObjectURL(blob); 43 | downloadLink.href = url; 44 | downloadLink.download = fileName; 45 | downloadLink.hidden = true; 46 | document.body.appendChild(downloadLink); 47 | downloadLink.click(); 48 | document.body.removeChild(downloadLink); 49 | } else { 50 | if (navigator.msSaveBlob) { 51 | //IE10+ 52 | navigator.msSaveBlob(blob, fileName); 53 | } 54 | } 55 | } 56 | }, 500); 57 | } 58 | 59 | function addlf(ele) { 60 | // console.log(ele.innerHTML); 61 | let attr = ele.getAttribute('style'); 62 | let str = ele.innerHTML; 63 | str = str.replace(/\s*/g, ""); 64 | let reg2 = /;false/; 65 | let hh = reg2.test(attr); 66 | if (hh && (!str)) { 67 | return 2; 68 | } else if ((!hh) && (!str)) { 69 | return 1; 70 | } else if (hh && str) { 71 | return 3; 72 | } else if (!hh && str) {} { 73 | return 4; 74 | } 75 | } 76 | 77 | // 蒙层 78 | function layer(index, max) { 79 | let Progress_bar_overlay = document.getElementById("Progress_bar_overlay"); 80 | if (Progress_bar_overlay) { 81 | try { 82 | Progress_bar_overlay.parentNode.removeChild(Progress_bar_overlay); 83 | } catch (error) { 84 | 85 | } 86 | 87 | } 88 | let Progress_bar_ov = document.getElementById("Progress_bar_ov"); 89 | if (Progress_bar_ov) { 90 | try { 91 | Progress_bar_ov.parentNode.removeChild(Progress_bar_ov); 92 | } catch (error) { 93 | 94 | } 95 | 96 | } 97 | if (index == max) { 98 | cancelDisMouseWheel(); 99 | try { 100 | Progress_bar_overlay.parentNode.removeChild(Progress_bar_overlay); 101 | Progress_bar_ov.parentNode.removeChild(Progress_bar_ov); 102 | } catch (error) { 103 | 104 | } 105 | 106 | return; 107 | } else { 108 | let mchtml = `
`; 109 | let prhtml = `
110 |
`; 111 | let divdom = document.createElement("div"); 112 | divdom.innerHTML = mchtml + prhtml; 113 | document.getElementsByTagName('body')[0].append(divdom); 114 | disabledMouseWheel(); //阻止滚动 115 | } 116 | } 117 | 118 | //阻止浏览器事件 119 | function disabledMouseWheel() { 120 | document.addEventListener('DOMMouseScroll', scrollFunc, false); 121 | document.addEventListener('mousewheel', scrollFunc, false); 122 | } 123 | //取消阻止浏览器事件 124 | function cancelDisMouseWheel() { 125 | document.removeEventListener('DOMMouseScroll', scrollFunc, false); 126 | document.removeEventListener('mousewheel', scrollFunc, false); 127 | } 128 | 129 | function scrollFunc(evt) { 130 | evt = evt || window.event; 131 | if (evt.preventDefault) { 132 | // Firefox 133 | evt.preventDefault(); 134 | evt.stopPropagation(); 135 | } else { 136 | // IE 137 | evt.cancelBubble = true; 138 | evt.returnValue = false; 139 | } 140 | return false; 141 | } 142 | } 143 | })() 144 | 145 | // style里面最后一个参数是false就要换行 146 | //1 换行 2 删除 3 不换行 147 | 148 | // 1. 全是ensp 没有false删除并且不换行 149 | // 2. 全是ensp,有false 删除并且换行 150 | // 3. str有值,有false 换行 151 | // 4. str有值,没有false 不换行 -------------------------------------------------------------------------------- /wenkudl/js/index.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var btn = document.getElementById('button'); 3 | btn.addEventListener('click', function(e) { 4 | chrome.tabs.getSelected(function(tab) { 5 | this.current_tab_id = tab.id; 6 | chrome.tabs.executeScript(tab.id, { file: 'js/getData.js' }); 7 | chrome.tabs.executeScript(tab.id, { file: 'js/jq.js' }); 8 | }); 9 | }); 10 | 11 | })() -------------------------------------------------------------------------------- /wenkudl/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "wenkudl", 4 | "description": "wenku download", 5 | "version": "1.0", 6 | "icons": { 7 | "16": "imgs/logo16.png", 8 | "48": "imgs/logo48.png", 9 | "128": "imgs/logo128.png" 10 | }, 11 | "background": { 12 | "page": "index.html" 13 | }, 14 | 15 | "browser_action": { 16 | "default_icon": "imgs/logo128.png", 17 | "default_popup": "index.html", 18 | "default_title": "" 19 | }, 20 | "content_security_policy": "script-src 'self'; object-src 'self'", 21 | "permissions": ["activeTab", "tabs", "notifications", "webRequest", "http://*/*", "https://*/*"] 22 | } 23 | --------------------------------------------------------------------------------