├── .gitignore ├── LICENSE ├── README.md ├── build ├── hooker-mini.js ├── hooker-mini.js.LICENSE.txt └── hooker.js ├── demo ├── aHook-testing-2.html ├── aHook-testing-3.html ├── aHook-testing-4.html ├── aHook-testing.html ├── demo-hook-class.html ├── dome-hook-jquery.html ├── hooking-ajax.html ├── lib │ ├── ajax.js │ └── jquery-3.1.1.js └── npm-test.js ├── package-lock.json ├── package.json ├── src ├── hooker.js └── plugins │ ├── copying-lifted │ ├── LICENSE │ ├── copyingLifted.js │ └── readme.md │ ├── hookAll.js │ ├── timer-hooker │ ├── LICENSE │ ├── readme.md │ ├── time-hooker-style.html │ └── timeHooker.js │ └── wenku2word │ ├── readme.md │ └── wenku2word.js └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | node_modules 3 | out -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Hooker JS [![gitee.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNTQyMTMwNzVXcWZyU2dTbC5wbmc=&w=15)](https://gitee.com/HGJing/hooker-js) [![github.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNjU3NDkzMDkybWNLRXhHMi5wbmc=&w=15)](https://github.com/canguser/hooker-js) 2 | 3 | > **注意,`Hooker JS` 由于版本问题和历史代码问题,已停止该代码库对应版本的维护** 4 | > 5 | > **新版本已改名为[`@hook-js`](https://github.com/canguser/hook-js-core):[https://github.com/canguser/hook-js-core](https://github.com/canguser/hook-js-core)** 6 | 7 | > 用于劫持方法,对目标进行 AOP 切面操作 8 | 基于 ES5 语法,用于快速开发 9 | 10 | ---------- 11 | 12 | ## 快速入门 13 | 14 | ```javascript 15 | eHook.hookBefore(window,'alert',function(method,args){ 16 | args[0] = args[0] + '[被劫持的参数]'; 17 | }); 18 | alert('hello eHook'); // hello eHook[被劫持的参数] 19 | ``` 20 | 21 | 全局对象:`eHook`,`aHook` 22 | 23 | - `eHook`:包含aop劫持的基本方法 24 | - `aHook`:包含 Ajax Url 劫持的基本方法 25 | 26 | ## 引入方法 27 | 1. 下载源码中的 `hooker.js` 或 `hooker-mini.js` 位于目录 `/build`,然后通过 ` 13 | 14 | 24 | 25 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /demo/aHook-testing-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | AHook Testing 3 11 | 18 | 19 | 20 | 32 | 33 | 34 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /demo/aHook-testing-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Title 11 | 18 | 19 | 20 | 21 | 31 | 32 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /demo/aHook-testing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | AHook Testing 11 | 12 | 13 | 20 | 21 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /demo/demo-hook-class.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Title 7 | 8 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /demo/dome-hook-jquery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hook JQuery 6 | 7 | 8 | 9 | 10 | 35 | 36 | 37 | 38 | 39 |
40 | 41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /demo/hooking-ajax.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Ajax Hook Testing 11 | 12 | 13 | 28 | 29 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /demo/lib/ajax.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Eoly on 2017/5/8. 3 | * Call https://palerock.cn 4 | */ 5 | var Ajax = function (conf) { 6 | if (!conf || typeof conf != 'object') { 7 | throw new Error('配置类型错误'); 8 | } 9 | if (conf.params && typeof conf.params === 'object') { 10 | var params = conf.params; 11 | for (var name in params) { 12 | if (params.hasOwnProperty(name)) 13 | if (params[name]) { 14 | if (typeof params[name] != 'string') { 15 | continue; 16 | } 17 | if (conf.url.indexOf('?') !== -1) { 18 | conf.url = conf.url + '&' + name + '=' + params[name]; 19 | } else { 20 | conf.url = conf.url + '?' + name + '=' + params[name]; 21 | } 22 | } 23 | } 24 | } 25 | Ajax.sentRequest(conf); 26 | return Ajax; 27 | }; 28 | Ajax.get = function () { 29 | }; 30 | Ajax.then = function (suc, fail) { 31 | Ajax.OnSuccess = suc; 32 | Ajax.OnFailure = fail; 33 | }; 34 | Ajax.OnFailure = function (result) { 35 | }; 36 | Ajax.OnSuccess = function (result) { 37 | }; 38 | Ajax.onReady = function (e) { 39 | // console.log(e.srcElement.patcherList,e); 40 | var element = e.srcElement; 41 | var result = {}; 42 | if (element.status >= 200 && element.status < 400) { 43 | try { 44 | result.data = JSON.parse(element.responseText); 45 | } catch (ex) { 46 | result.data = element.responseText; 47 | } 48 | this.OnSuccess(result.data); 49 | } else if (element.status >= 400) { 50 | this.OnFailure(result); 51 | } 52 | }; 53 | Ajax.sentRequest = function (conf) { 54 | var xhr = new XMLHttpRequest(); 55 | xhr.open(conf.method, conf.url, conf.async); 56 | xhr.onreadystatechange = function (e) { 57 | if (xhr.readyState == 4) { 58 | Ajax.onReady(e) 59 | } 60 | }; 61 | xhr.send(); 62 | }; -------------------------------------------------------------------------------- /demo/npm-test.js: -------------------------------------------------------------------------------- 1 | var hookJS = require('../build/hook-js-mini'); 2 | 3 | var eHook = hookJS.eHook; 4 | 5 | eHook.hookBefore( 6 | console, 'log', function (m, args) { 7 | args[1] = 'logged after'; 8 | } 9 | ); 10 | 11 | console.log('hello HookJS', '?'); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@palerock/hooker-js", 3 | "version": "0.5.9056", 4 | "description": "用于劫持方法,进行AOP切面操作", 5 | "main": "build/hooker.js", 6 | "scripts": { 7 | "build-source": "webpack --progress --env production=false ", 8 | "build-mini": "webpack --env production=true --progress", 9 | "build": "npm run build-source && npm run build-mini", 10 | "do-publish": "npm publish --access public" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/cangshi/hooker-js.git" 15 | }, 16 | "keywords": [ 17 | "hook", 18 | "javascript", 19 | "es5" 20 | ], 21 | "files": [ 22 | "build" 23 | ], 24 | "author": "Cangshi", 25 | "license": "Apache License 2.0", 26 | "devDependencies": { 27 | "webpack": "^5.2.0", 28 | "webpack-cli": "^4.1.0" 29 | }, 30 | "dependencies": { 31 | "@palerock/every-utils": "^0.2.2" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/plugins/copying-lifted/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright © 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 13 | 14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 15 | 16 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 17 | 18 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 19 | 20 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 21 | 22 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 23 | 24 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 25 | 26 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 27 | 28 | The precise terms and conditions for copying, distribution and modification follow. 29 | 30 | TERMS AND CONDITIONS 31 | 32 | 0. Definitions. 33 | "This License" refers to version 3 of the GNU General Public License. 34 | 35 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 36 | 37 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. 38 | 39 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. 40 | 41 | A "covered work" means either the unmodified Program or a work based on the Program. 42 | 43 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 44 | 45 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 46 | 47 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 48 | 49 | 1. Source Code. 50 | The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. 51 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 52 | 53 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 54 | 55 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 56 | 57 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 58 | 59 | The Corresponding Source for a work in source code form is that same work. 60 | 61 | 2. Basic Permissions. 62 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 63 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 64 | 65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 66 | 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 69 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 70 | 71 | 4. Conveying Verbatim Copies. 72 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 73 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 74 | 75 | 5. Conveying Modified Source Versions. 76 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 77 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 78 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". 79 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 80 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 81 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 82 | 83 | 6. Conveying Non-Source Forms. 84 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 85 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 86 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 87 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 88 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 89 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 90 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 91 | 92 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 93 | 94 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 95 | 96 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 97 | 98 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 99 | 100 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 101 | 102 | 7. Additional Terms. 103 | "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 104 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 105 | 106 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 107 | 108 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 109 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 110 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 111 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 112 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 113 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 114 | All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 115 | 116 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 117 | 118 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 119 | 120 | 8. Termination. 121 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 122 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 123 | 124 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 125 | 126 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 127 | 128 | 9. Acceptance Not Required for Having Copies. 129 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 130 | 10. Automatic Licensing of Downstream Recipients. 131 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 132 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 133 | 134 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 135 | 136 | 11. Patents. 137 | A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". 138 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 139 | 140 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 141 | 142 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 143 | 144 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 145 | 146 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 147 | 148 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 149 | 150 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 151 | 152 | 12. No Surrender of Others' Freedom. 153 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 154 | 13. Use with the GNU Affero General Public License. 155 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 156 | 14. Revised Versions of this License. 157 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 158 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 159 | 160 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 161 | 162 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 163 | 164 | 15. Disclaimer of Warranty. 165 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 166 | 16. Limitation of Liability. 167 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 168 | 17. Interpretation of Sections 15 and 16. 169 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 170 | 171 | END OF TERMS AND CONDITIONS 172 | 173 | How to Apply These Terms to Your New Programs 174 | 175 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 176 | 177 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 178 | 179 | 180 | Copyright (C) 181 | 182 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 183 | 184 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 185 | 186 | You should have received a copy of the GNU General Public License along with this program. If not, see . 187 | 188 | Also add information on how to contact you by electronic and paper mail. 189 | 190 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 191 | 192 | TimeHooker Copyright (C) 2020 palerock.cn 193 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 194 | This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. 195 | 196 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". 197 | 198 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 199 | 200 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . -------------------------------------------------------------------------------- /src/plugins/copying-lifted/copyingLifted.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Copying Lifted 解除复制限制 3 | // @name:en Copying Lifted 4 | // @name:zh-CN Copying Lifted 解除复制限制 5 | // @namespace https://palerock.cn 6 | // @version 0.3 7 | // @description:en Allow your copying in anywhere. 8 | // @description:zh-CN 让你在几乎所有网页里自由地复制粘贴,而不用担心被限制,或者被篡改复制内容 9 | // @require https://greasyfork.org/scripts/372672-everything-hook/code/Everything-Hook.js?version=659315 10 | // @include * 11 | // @author Cangshi 12 | // @match http://*/* 13 | // @run-at document-start 14 | // @grant none 15 | // ==/UserScript== 16 | 17 | function removeCopyEvent() { 18 | Array.prototype.concat.call(document.querySelectorAll('*'), document) 19 | .forEach(function (ele) { 20 | ele.oncopy = undefined; 21 | ele.oncontextmenu = undefined; 22 | }); 23 | } 24 | 25 | 'use strict'; 26 | ~function (global) { 27 | function generate() { 28 | return function () { 29 | 30 | global.addEventListener('contextmenu', function (e) { 31 | removeCopyEvent(); 32 | }); 33 | 34 | global.addEventListener('keydown', function (e) { 35 | if (e.ctrlKey || e.keyCode === 224 || e.keyCode === 17 || e.keyCode === 91 || e.keyCode === 93) { 36 | removeCopyEvent(); 37 | } 38 | }); 39 | 40 | this.hookBefore(EventTarget.prototype, 'addEventListener', 41 | function (m, args) { 42 | if (args[0] === 'copy' || args[0] === 'contextmenu') { 43 | args[0] = 'prevent ' + args[0] + ' handler'; 44 | console.log('[AllowCopy Plugins]', args[0]); 45 | } 46 | }, false); 47 | 48 | var style = 'body * :not(input):not(textarea){-webkit-user-select:auto!important;-moz-user-select:auto!important;-ms-user-select:auto!important;user-select:auto!important}'; 49 | 50 | var stylenode = document.createElement('style'); 51 | 52 | stylenode.setAttribute("type", "text/css"); 53 | if (stylenode.styleSheet) {// IE 54 | stylenode.styleSheet.cssText = style; 55 | } else {// w3c 56 | var cssText = document.createTextNode(style); 57 | stylenode.appendChild(cssText); 58 | } 59 | 60 | document.addEventListener('readystatechange', function () { 61 | if (document.readyState === "interactive" || document.readyState === "complete") { 62 | setTimeout(function () { 63 | document.head.appendChild(stylenode); 64 | console.log('[AllowCopy Plugins] css applied') 65 | }, 2000); 66 | } 67 | }); 68 | 69 | console.log('[AllowCopy Plugins]', 'works.'); 70 | } 71 | } 72 | 73 | 74 | if (global.eHook) { 75 | global.eHook.plugins({ 76 | name: 'allowCopy', 77 | /** 78 | * 插件装载 79 | * @param util 80 | */ 81 | mount: generate() 82 | }); 83 | } 84 | }(window); -------------------------------------------------------------------------------- /src/plugins/copying-lifted/readme.md: -------------------------------------------------------------------------------- 1 | # 解除复制限制 [![gitee.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNTQyMTMwNzVXcWZyU2dTbC5wbmc=&w=20)](https://gitee.com/HGJing/everthing-hook/tree/master/src/plugins/copying-lifted "Gitee") [![github.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNjU3NDkzMDkybWNLRXhHMi5wbmc=&w=20)](https://github.com/canguser/hooker-js/tree/master/src/plugins/copying-lifted "Github") 2 | ## Copying Lifted 3 | 4 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/views-info/416195) 5 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/stats/daily-installs/416195) 6 | ![Daily Updates](https://palerock.cn/node-service/images/greasyfork/stats/daily-updates/416195) 7 | ![Total Installs](https://palerock.cn/node-service/images/greasyfork/stats/total-installs/416195) 8 | 9 | ## 特征 10 | ### 1. 解除烦人的复制限制! 11 | ### 2. 对几乎所有网页生效! 12 | ### 3. 简单高效! 13 | ### 4. 轻松屏蔽一些网页在你复制的内容后加上一些后缀 14 | ### 5. 类似的插件很多,我只是想做一款简单一点,满足日常使用便足矣 15 | 16 | ### [安装该插件](https://greasyfork.org/zh-CN/scripts/416195)即刻生效! 17 | 18 | ### 现在同样可以解除右键菜单了,不过和某些自定义右键菜单的网页冲突,建议手动排除 19 | 20 | ### 有问题请及时反馈! 21 | 22 | ## 版本信息 23 | - 0.3 [2020-12.07] 增强解除复制限制的功能,现在同样可以解除右键菜单了,不过和某些自定义右键菜单的网页冲突,建议手动排除 24 | - 0.2 [2020-12-03] 解决在一些网站不能解除复制限制的问题,如 mooc 网 25 | - 0.1 [2020-11-16] 基础功能第一版 26 | -------------------------------------------------------------------------------- /src/plugins/hookAll.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name Hook all ajax 3 | // @namespace https://gitee.com/HGJing/everthing-hook/ 4 | // @version 0.1.018 5 | // @description it can hook all ajax 6 | // @include * 7 | // @require http://localhost:63342/everthing-hook/src/everything-hook.js 8 | // @author Cangshi 9 | // @match *://*/* 10 | // @run-at document-start 11 | // @grant none 12 | // ==/UserScript== 13 | 14 | (function (global) { 15 | 'use strict'; 16 | if (global.eHook) { 17 | global.eHook.plugins({ 18 | name: 'NetHook', 19 | /** 20 | * 插件装载 21 | * @param util 22 | */ 23 | mount: function (util) { 24 | var cbObject = { 25 | resp: {}, 26 | parseScript: function (m, args) { 27 | if (args[0].localName !== 'script') { 28 | return; 29 | } 30 | var src = decodeURI(args[0].src); 31 | var isPass = true; 32 | if (ajaxObject.filterPatten) { 33 | isPass = util.urlUtils.urlMatching(src, ajaxObject.filterPatten); 34 | } 35 | if (!isPass || !ajaxChange.cb.req) { 36 | return; 37 | } 38 | var urls = src.split(','); 39 | if (urls.length > 1) { 40 | return; 41 | } 42 | args[0].requestParams = util.urlUtils.getParamFromUrl(src); 43 | args[0].requestUrl = util.urlUtils.getUrlWithoutParam(src); 44 | ajaxChange.cb.req.call(this, args[0], util); 45 | var aimedUrl = util.urlUtils.margeUrlAndParams(args[0].requestUrl, args[0].requestParams); 46 | if (aimedUrl !== src) { 47 | args[0].src = aimedUrl; 48 | } 49 | var cbName = undefined; 50 | args[0].requestParams.map(function (kv) { 51 | if (kv.key.toLowerCase() === 'cb' || kv.key.toLowerCase() === 'callback') { 52 | cbName = kv.value; 53 | } 54 | }); 55 | if (!cbName || !ajaxChange.cb.resp) { 56 | return; 57 | } 58 | if (window[cbName]) { 59 | global.eHook.removeHookMethod(window, cbName); 60 | global.eHook.hookBefore(window, cbName, function (m, args) { 61 | ajaxChange.cb.resp.call(window, args, util); 62 | // console.log('Hooking call back: ' + cbName + ' success.') 63 | }, false); 64 | } else { 65 | var isDelete = false; 66 | try { 67 | isDelete = delete window[cbName] 68 | } catch (e) { 69 | isDelete = false; 70 | } 71 | if (isDelete) { 72 | Object.defineProperty(window, cbName, { 73 | set: function (v) { 74 | global.eHook.unHook(cbObject.resp, cbName, true); 75 | cbObject.resp[cbName] = v; 76 | global.eHook.hookBefore(cbObject.resp, 77 | cbName, function (m, args) { 78 | ajaxChange.cb.resp.call(this, args, util); 79 | }); 80 | }, 81 | get: function () { 82 | return cbObject.resp[cbName]; 83 | } 84 | }); 85 | console.log('Hooking(proxy) call back: ' + cbName + ' success.') 86 | } else { 87 | console.log('Hooking call back: ' + cbName + ' failed.') 88 | } 89 | } 90 | 91 | } 92 | }; 93 | var isAutoInit = localStorage.getItem('__hook_all_auto_init'); 94 | if (!isAutoInit) { 95 | localStorage.setItem('__hook_all_auto_init', JSON.stringify(true)); 96 | isAutoInit = localStorage.getItem('__hook_all_auto_init'); 97 | } 98 | var ajaxObject = { 99 | filterPatten: '', 100 | isAutoInit: isAutoInit && isAutoInit !== 'false' 101 | }; 102 | var ajaxChange = { 103 | filter: function (pattern) { 104 | ajaxObject.filterPatten = pattern; 105 | return this; 106 | }, 107 | ajax: { 108 | req: undefined, 109 | resp: undefined, 110 | send: undefined 111 | }, 112 | cb: { 113 | req: undefined, 114 | resp: undefined 115 | }, 116 | setting: { 117 | autoInit: function (b) { 118 | ajaxObject.isAutoInit = b; 119 | localStorage.setItem('__hook_all_auto_init', JSON.stringify(b)); 120 | } 121 | }, 122 | init: function () { 123 | // hook jsonp 124 | global.eHook.hookBefore(Node.prototype, 'appendChild', function (m, args) { 125 | cbObject.parseScript(m, args); 126 | }, false); 127 | global.eHook.hookBefore(Node.prototype, 'insertBefore', function (m, args) { 128 | cbObject.parseScript(m, args); 129 | }, false); 130 | 131 | global.aHook.register('.*', { 132 | hookResponse: function () { 133 | var isPass = true; 134 | if (ajaxObject.filterPatten) { 135 | isPass = util.urlUtils.urlMatching(this.responseURL, ajaxObject.filterPatten); 136 | } 137 | return !isPass ? undefined : ajaxChange.ajax.resp && ajaxChange.ajax.resp.call(this, arguments, util); 138 | }, 139 | hookSend: function (args) { 140 | var isPass = true; 141 | if (ajaxObject.filterPatten) { 142 | isPass = util.urlUtils.urlMatching(this.requestURL, ajaxObject.filterPatten); 143 | } 144 | return !isPass ? undefined : ajaxChange.ajax.send && ajaxChange.ajax.send.call(this, arguments, util); 145 | }, 146 | hookRequest: function (args) { 147 | window.util = util; 148 | var isPass = true; 149 | if (ajaxObject.filterPatten) { 150 | isPass = util.urlUtils.urlMatching(args.fullUrl, ajaxObject.filterPatten); 151 | } 152 | this.requestURL = args.fullUrl; 153 | return !isPass ? undefined : ajaxChange.ajax.req && ajaxChange.ajax.req.call(this, arguments, util); 154 | } 155 | } 156 | ); 157 | }, 158 | onInit: function () { 159 | } 160 | }; 161 | ajaxChange.onInit(); 162 | // if (ajaxObject.isAutoInit) { 163 | ajaxChange.init(); 164 | // } 165 | 166 | return ajaxChange; 167 | } 168 | }); 169 | } 170 | })(window); -------------------------------------------------------------------------------- /src/plugins/timer-hooker/LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright © 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. 13 | 14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 15 | 16 | To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. 17 | 18 | For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. 19 | 20 | Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. 21 | 22 | For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. 23 | 24 | Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. 25 | 26 | Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. 27 | 28 | The precise terms and conditions for copying, distribution and modification follow. 29 | 30 | TERMS AND CONDITIONS 31 | 32 | 0. Definitions. 33 | "This License" refers to version 3 of the GNU General Public License. 34 | 35 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 36 | 37 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. 38 | 39 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. 40 | 41 | A "covered work" means either the unmodified Program or a work based on the Program. 42 | 43 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 44 | 45 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 46 | 47 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 48 | 49 | 1. Source Code. 50 | The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. 51 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 52 | 53 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 54 | 55 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. 56 | 57 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 58 | 59 | The Corresponding Source for a work in source code form is that same work. 60 | 61 | 2. Basic Permissions. 62 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 63 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 64 | 65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 66 | 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 69 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 70 | 71 | 4. Conveying Verbatim Copies. 72 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 73 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 74 | 75 | 5. Conveying Modified Source Versions. 76 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 77 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 78 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". 79 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 80 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 81 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 82 | 83 | 6. Conveying Non-Source Forms. 84 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 85 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 86 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 87 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 88 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 89 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 90 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 91 | 92 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 93 | 94 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 95 | 96 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 97 | 98 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 99 | 100 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 101 | 102 | 7. Additional Terms. 103 | "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 104 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 105 | 106 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 107 | 108 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 109 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 110 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 111 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 112 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 113 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 114 | All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 115 | 116 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 117 | 118 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 119 | 120 | 8. Termination. 121 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 122 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 123 | 124 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 125 | 126 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 127 | 128 | 9. Acceptance Not Required for Having Copies. 129 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 130 | 10. Automatic Licensing of Downstream Recipients. 131 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 132 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 133 | 134 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 135 | 136 | 11. Patents. 137 | A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". 138 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 139 | 140 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 141 | 142 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 143 | 144 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 145 | 146 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 147 | 148 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 149 | 150 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 151 | 152 | 12. No Surrender of Others' Freedom. 153 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 154 | 13. Use with the GNU Affero General Public License. 155 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 156 | 14. Revised Versions of this License. 157 | The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 158 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. 159 | 160 | If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 161 | 162 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 163 | 164 | 15. Disclaimer of Warranty. 165 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 166 | 16. Limitation of Liability. 167 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 168 | 17. Interpretation of Sections 15 and 16. 169 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 170 | 171 | END OF TERMS AND CONDITIONS 172 | 173 | How to Apply These Terms to Your New Programs 174 | 175 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 176 | 177 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 178 | 179 | 180 | Copyright (C) 181 | 182 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 183 | 184 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 185 | 186 | You should have received a copy of the GNU General Public License along with this program. If not, see . 187 | 188 | Also add information on how to contact you by electronic and paper mail. 189 | 190 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 191 | 192 | TimeHooker Copyright (C) 2020 palerock.cn 193 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 194 | This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. 195 | 196 | The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". 197 | 198 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . 199 | 200 | The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . -------------------------------------------------------------------------------- /src/plugins/timer-hooker/readme.md: -------------------------------------------------------------------------------- 1 | # 计时器掌控者,视频广告一秒跳过,倒计时瞬间归零,几乎支持所有网站 [![gitee.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNTQyMTMwNzVXcWZyU2dTbC5wbmc=&w=20)](https://gitee.com/HGJing/hooker-js/tree/master/src/plugins/timer-hooker "Gitee") [![github.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNjU3NDkzMDkybWNLRXhHMi5wbmc=&w=20)](https://github.com/canguser/hooker-js/tree/master/src/plugins/timer-hooker "Github") 2 | 3 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/views-info/372673) 4 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/stats/daily-installs/372673) 5 | ![Daily Updates](https://palerock.cn/node-service/images/greasyfork/stats/daily-updates/372673) 6 | ![Total Installs](https://palerock.cn/node-service/images/greasyfork/stats/total-installs/372673) 7 | ![得分](https://palerock.cn/node-service/images/greasyfork/info/fan_score/372673?name=得分&rcolor=orange) 8 | ![好评](https://palerock.cn/node-service/images/greasyfork/info/good_ratings/372673?name=好评&rcolor=darkcyan) 9 | ![许可证](https://palerock.cn/node-service/images/greasyfork/info/license/372673?name=许可证&rcolor=blueviolet) 10 | 11 | > 支持几乎所有视频网站和用于其他用途的任一网站,可以自行发掘出更多的用处。 12 | 原理是**控制网页计时器**,几乎**所有**通过计时器实现的内容都可以变速。 13 | > 14 | > 欢迎加入 Q群 讨论:140783474 15 | 16 | ### `2.0.5+` 全新版本已上线:[计时器掌控者 2.x 主页](https://timer.palerock.cn) 17 | 18 | > 2.0.5 版本新特性:脚本可配置化(自定义倍率,自定义快捷键,自定义悬浮球位置等) 19 | 20 | **最新版本直装链接:[计时器掌控者](https://palerock.cn/node-service/scripts/install/@hook-js_timer/hook.timer.user.js)** 21 | 22 | > **通过 GreasyFork 安装为遗留版本的脚本,但是依然会在后期进行功能性的维护,仍可放心使用** 23 | 24 | ### 使用方法: 25 | 1. 点击安装(地址:[GreasyFork](https://greasyfork.org/scripts/372673)) 26 | 2. 网页左边有悬浮的能量球,鼠标移动过去有加速选项,你可以选择加速或减速,最上面的悬浮球表明现在的倍速 27 | 3. 加速跳过某广告后,需要点击最后一个悬浮球恢复默认速度 28 | 4. 该插件支持所有的网页限时广告的跳过,如腾讯,爱奇艺,优酷等等。 29 | 5. 快捷键操作: 30 | - `’ctrl‘+‘=’` 或 `’ctrl‘+'>'` : 倍率+2 31 | - `’alt‘+‘=’` 或 `’alt‘+‘>’` : 倍率x2 32 | - `’ctrl‘+‘-’` 或 `’ctrl‘+‘<’` : 倍率-2 33 | - `’alt‘+‘-’` 或 `’ctrl‘+‘<’` : 倍率/2 34 | - `’ctrl‘+‘0’` 或 `’alt‘+‘0’` : 倍率恢复为1 35 | - `’ctrl‘+‘9’` 或 `’alt‘+‘9’` : 弹出自定义倍率输入框 36 | 6. 在播放视频时,使用该插件可以对视频快进或慢放(注意必须使用 HTML5 视频播放器,Flash 播放器是无效的哦) 37 | 7. **最后,创作不易,喜欢该插件的朋友可以扫描最下方的二维码,捐赠作者,你的鼓励就是我的动力,谢谢!** 38 | 39 | > 由于不同使用人群使用该插件可能基于不同目的,一些较小众的功能需求不会作为更新推送给所有人,如有需要可以有偿捐赠并留言 40 | 41 | ### 关于反馈 42 | - 欢迎各种反馈或建议,拒绝恶意差评 43 | - 如果是插件在任何网站都不生效,那肯定是环境问题,请检查以下几点 44 | - 浏览器内核是否为 webkit,推荐谷歌浏览器 45 | - 尝试关闭其它插件并重新安装后再试 46 | - 清理浏览器缓存 47 | - 如果是某个网站不能生效或者影响该网站的正常显示,请以以下格式反馈在 [https://greasyfork.org/scripts/372673/feedback](https://greasyfork.org/scripts/372673/feedback) 48 | 具体格式如下: 49 | 50 | ``` 51 | 网站链接:(必须给出具体页面的链接,不能是一个大的网页,如果需要登录才能看到,需要私信用户名以及密码) 52 | 反馈原因: (计时器不生效/影响网页正常使用/建议) 53 | 描述:(描述具体情况,以方便找到问题并修复) 54 | ``` 55 | 56 | **必须遵循该格式,否则反馈一律无视!** 57 | 58 | 在版本修复前可以自己添加规则排除该插件对指定网站生效: [油猴插件怎么配置能让插件只在特定的网页生效?](https://palerock.cn/articles/001w1s6gHGV) 59 | 60 | - 加入 QQ 群进行反馈 61 | 62 | ![image.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMTA1MDgxMjE1MTY2OTVXQW5OODBNRi5wbmc=&w=300) 63 | 64 | ### 更新日志 65 | 66 | - 2021-04-17 [1.0.61 - 1.0.62] 67 | - 修复某些网页视频加速失效的问题,如百度云盘 68 | 69 | - 2021-03-12 [1.0.60] 70 | - 修复某些网页视频加速失效的问题,如腾讯视频(百度云的视频不能确定是否已修复,望大家测试后反馈) 71 | 72 | - 2021-01-28 [1.0.58 - 1.0.59] 73 | - 修复传统计时器有时会控制失效的问题 74 | 75 | - 2020-12-18 [1.0.52 - 1.0.57] 76 | - 修复在一些网站中图片无法加载的问题 77 | 78 | - 2020-11-30 [1.0.51] 79 | 1. 新增快捷键:`’ctrl‘+‘9’` 或 `’alt‘+‘9’` : 弹出自定义倍率输入框 80 | 2. 将以前乘4倍率或除以4倍率都改为乘2或除以2 81 | 3. 修改鼠标触发悬浮球的范围,现在只有当鼠标移到第一个悬浮球才会触发其它悬浮按钮 82 | 4. 修改悬浮球以及倍率改变结果样式 83 | 84 | - 2020-08-10 [1.0.50] 85 | 86 | 修复在一些网站中(如:Twitter)悬浮球点击无效的问题 87 | 88 | - 2020-04-05 [1.0.39] 89 | 90 | 修复一些网站兼容问题,现在可以正常的在大部分网页中正常工作了 91 | 92 |
查看更早的更新 93 |

94 |
95 | - 2020-03-27 [1.0.37] 96 | 97 | 修复影响iCloud等网站的页面正常加载的问题 98 | 99 | 优化算法以避免多次出现影响相应网站加载的问题 100 |
101 | - 2020-03-19 [1.0.31] 102 | 103 | 现在只会出现一个悬浮球了,在网页的最左边,这个悬浮球可以控制所有的视频或计时器 104 | 105 | 现在悬浮球会更快的出现在页面中 106 | 107 | 界面小幅度修改 108 |
109 | - 2020-03-16 [1.0.20] 110 | 111 | 修复一个问题,该问题导致但不限于 B 站中的视频再变速后无法暂停 112 |
113 | - 2020-03-03 [1.0.10] 114 | 115 | 修复在某些网站中无法加速的issue, 如在百度网盘中播放视频 116 |
117 | - 2020-02-27 [1.0.09] 118 | 119 | 修复在部分网页中其网页内容无法点击的问题 120 |
121 | - 2019-12-02 [1.0.01] 122 | 123 | 代码小部分重构,提升版本号 124 | 125 | 修复一些小问题 126 |
127 | - 2019-09-05 [0.3.0003] 128 | 129 | 修复在一些网站加载异常的问题。 130 |
131 | - 2019-08-27 [0.3.0001] 132 | 133 | (实验性特性)支持优酷广告跳过 134 | 135 | (实验性特性)现在加速也对HTML5视频生效,这意味着你可以对视频快进或慢放啦。 136 |
137 | - 2019-01-10 [0.2.0111] 138 | 139 | 快捷键微调,原来的快捷键不变,现在也可以使用按键 '<' 和 '>' 代替 '-' 和 '=' 的功能,以防止快捷键冲突。具体看上面第五点快捷键操作。 140 |
141 | - 2018-12-26 [0.2.0105] 142 | 143 | 大版本issue修复,修复大部分网页打开出错的问题。 144 | 145 | 测试特性:现在对网页加速也会加速网页的时间流逝(即浏览器获取到的本地时间也会随时间加速而获取到加速后的时间)。 146 | 147 | 例如:加速前获取当前时间是10.00am, 60倍加速持续1分钟,此时获取当前时间就不该是10.01am而是11.00am 148 |
149 | - 2018-11-19 [0.2.0049] 150 | 151 | 测试性修复一些网页无法正常工作的issue 152 |
153 | - 2018-10-30 [0.2.0048] 154 | 155 | 更正天猫页面显示不正常的issue 156 |
157 | - 2018-10-21 [0.2.0047] 158 | 159 | 修复会影响JD登录的bug 160 |
161 | - 2018-10-08 [0.2.0045] 162 | 163 | 修复在爱奇艺中无法工作的情况 164 |
165 | - 2018-09-29 [0.2.0022] 166 | 167 | 修正快捷键操作:’ctrl‘+‘=’ : 倍率+2, ’alt‘+‘=’ : 倍率x4, ’ctrl‘+‘-’ : 倍率-2, ’alt‘+‘-’ : 倍率/4, ’ctrl‘+‘0’ 或 ’alt‘+‘0’ : 倍率恢复为1 168 |
169 | - 2018-09-29 [0.2.0020] 170 | 171 | 支持快捷键操作:’ctrl‘+‘=’ : 倍率+2, ’shift‘+‘=’ : 倍率x4, ’ctrl‘+‘-’ : 倍率-2, ’shift‘+‘-’ : 倍率/4, ’ctrl‘+‘0’ : 倍率恢复为1 172 | 173 | 全屏显示倍率信息 174 |
175 |

176 |
177 | 178 | ### 其它 179 | 180 | 项目首页:[https://palerock.cn/projects/0060cG6sIfY](https://palerock.cn/projects/0060cG6sIfY) 181 | 开源地址: 182 | - Gitee: [https://gitee.com/HGJing/hooker-js/tree/master/src/plugins/timer-hooker](https://gitee.com/HGJing/hooker-js/tree/master/src/plugins/timer-hooker) 183 | - Github: [https://github.com/canguser/hooker-js/tree/master/src/plugins/timer-hooker](https://github.com/canguser/hooker-js/tree/master/src/plugins/timer-hooker) 184 | 185 | ## 喜欢该脚本 186 | 187 | ![image.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyNDA2MjUxMTU4MTMyNjE3TlBobGsxWC5wbmc=&w=400) 188 | 189 | 190 | 191 | > **转载,复用,修改该插件**需注明出处,未经允许**不得用于商用或盈利** 192 | **Created By**: [苍石居](https://palerock.cn) -------------------------------------------------------------------------------- /src/plugins/timer-hooker/time-hooker-style.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Title 11 | 311 | 312 | 313 |
314 |
315 | 1 316 |
317 |
>
318 |
<
319 |
>>
320 |
<<
321 |
O
322 |
323 |
324 |
x1324324234324
325 |
326 | 327 | -------------------------------------------------------------------------------- /src/plugins/timer-hooker/timeHooker.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 计时器掌控者|视频广告跳过|视频广告加速器 3 | // @name:en TimerHooker 4 | // @namespace https://gitee.com/HGJing/everthing-hook/ 5 | // @updateURL https://gitee.com/HGJing/everthing-hook/raw/master/src/plugins/timeHooker.js 6 | // @version 1.0.62 7 | // @description 控制网页计时器速度|加速跳过页面计时广告|视频快进(慢放)|跳过广告|支持几乎所有网页. 8 | // @description:en it can hook the timer speed to change. 9 | // @include * 10 | // @require https://greasyfork.org/scripts/372672-everything-hook/code/Everything-Hook.js?version=881251 11 | // @author Cangshi 12 | // @match http://*/* 13 | // @run-at document-start 14 | // @grant none 15 | // @license GPL-3.0-or-later 16 | // ==/UserScript== 17 | /** 18 | * --------------------------- 19 | * Time: 2017/11/20 19:28. 20 | * Author: Cangshi 21 | * View: http://palerock.cn 22 | * --------------------------- 23 | */ 24 | 25 | /** 26 | * 1. hook Object.defineProperty | Object.defineProperties 27 | * 2. set configurable: true 28 | * 3. delete property 29 | * 4. can set property for onxx event method 30 | */ 31 | 32 | window.isDOMLoaded = false; 33 | window.isDOMRendered = false; 34 | 35 | document.addEventListener('readystatechange', function () { 36 | if (document.readyState === "interactive" || document.readyState === "complete") { 37 | window.isDOMLoaded = true; 38 | } 39 | }); 40 | 41 | ~function (global) { 42 | 43 | var workerURLs = []; 44 | var extraElements = []; 45 | var suppressEvents = {}; 46 | 47 | var helper = function (eHookContext, timerContext, util) { 48 | return { 49 | applyUI: function () { 50 | var style = '._th-container ._th-item{margin-bottom:3px;position:relative;width:0;height:0;cursor:pointer;opacity:.3;background-color:aquamarine;border-radius:100%;text-align:center;line-height:30px;-webkit-transition:all .35s;-o-transition:all .35s;transition:all .35s;right:30px}._th-container ._th-item,._th-container ._th-click-hover,._th_cover-all-show-times ._th_times{-webkit-box-shadow:-3px 4px 12px -5px black;box-shadow:-3px 4px 12px -5px black}._th-container:hover ._th-item._item-x2{margin-left:18px;width:40px;height:40px;line-height:40px}._th-container:hover ._th-item._item-x-2{margin-left:17px;width:38px;height:38px;line-height:38px}._th-container:hover ._th-item._item-xx2{width:36px;height:36px;margin-left:16px;line-height:36px}._th-container:hover ._th-item._item-xx-2{width:32px;height:32px;line-height:32px;margin-left:14px}._th-container:hover ._th-item._item-reset{width:30px;line-height:30px;height:30px;margin-left:10px}._th-click-hover{position:relative;-webkit-transition:all .5s;-o-transition:all .5s;transition:all .5s;height:45px;width:45px;cursor:pointer;opacity:.3;border-radius:100%;background-color:aquamarine;text-align:center;line-height:45px;right:0}._th-container:hover{left:-5px}._th-container{font-size:12px;-webkit-transition:all .5s;-o-transition:all .5s;transition:all .5s;left:-35px;top:20%;position:fixed;-webkit-box-sizing:border-box;box-sizing:border-box;z-index:100000;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}._th-container ._th-item:hover{opacity:.8;background-color:#5fb492;color:aliceblue}._th-container ._th-item:active{opacity:.9;background-color:#1b3a26;color:aliceblue}._th-container:hover ._th-click-hover{opacity:.8}._th-container:hover ._th-item{opacity:.6;right:0}._th-container ._th-click-hover:hover{opacity:.8;background-color:#5fb492;color:aliceblue}._th_cover-all-show-times{position:fixed;top:0;right:0;width:100%;height:100%;z-index:99999;opacity:1;font-weight:900;font-size:30px;color:#4f4f4f;background-color:rgba(0,0,0,0.1)}._th_cover-all-show-times._th_hidden{z-index:-99999;opacity:0;-webkit-transition:1s all;-o-transition:1s all;transition:1s all}._th_cover-all-show-times ._th_times{width:300px;height:300px;border-radius:50%;background-color:rgba(127,255,212,0.51);text-align:center;line-height:300px;position:absolute;top:50%;right:50%;margin-top:-150px;margin-right:-150px}'; 51 | 52 | var displayNum = (1 / timerContext._percentage).toFixed(2); 53 | 54 | // 在页面左边添加一个半圆便于修改 55 | var html = '
\n' + 56 | '
\n' + 57 | ' x' + displayNum + '\n' + 58 | '
\n' + 59 | '
>
\n' + 60 | '
<
\n' + 61 | '
>>
\n' + 62 | '
<<
\n' + 63 | '
O
\n' + 64 | '
\n' + 65 | '
\n' + 66 | '
x' + displayNum + '
\n' + 67 | '
' + 68 | ''; 69 | var stylenode = document.createElement('style'); 70 | stylenode.setAttribute("type", "text/css"); 71 | if (stylenode.styleSheet) {// IE 72 | stylenode.styleSheet.cssText = style; 73 | } else {// w3c 74 | var cssText = document.createTextNode(style); 75 | stylenode.appendChild(cssText); 76 | } 77 | var node = document.createElement('div'); 78 | node.innerHTML = html; 79 | 80 | var clickMapper = { 81 | '_item-input': function () { 82 | changeTime(); 83 | }, 84 | '_item-x2': function () { 85 | changeTime(2, 0, true); 86 | }, 87 | '_item-x-2': function () { 88 | changeTime(-2, 0, true); 89 | }, 90 | '_item-xx2': function () { 91 | changeTime(0, 2); 92 | }, 93 | '_item-xx-2': function () { 94 | changeTime(0, -2); 95 | }, 96 | '_item-reset': function () { 97 | changeTime(0, 0, false, true); 98 | } 99 | }; 100 | 101 | Object.keys(clickMapper).forEach(function (className) { 102 | var exec = clickMapper[className]; 103 | var targetEle = node.getElementsByClassName(className)[0]; 104 | if (targetEle) { 105 | targetEle.onclick = exec; 106 | } 107 | }); 108 | 109 | if (!global.isDOMLoaded) { 110 | document.addEventListener('readystatechange', function () { 111 | if ((document.readyState === "interactive" || document.readyState === "complete") && !global.isDOMRendered) { 112 | document.head.appendChild(stylenode); 113 | document.body.appendChild(node); 114 | global.isDOMRendered = true; 115 | console.log('Time Hooker Works!'); 116 | } 117 | }); 118 | } else { 119 | document.head.appendChild(stylenode); 120 | document.body.appendChild(node); 121 | global.isDOMRendered = true; 122 | console.log('Time Hooker Works!'); 123 | } 124 | }, 125 | applyGlobalAction: function (timer) { 126 | // 界面半圆按钮点击的方法 127 | timer.changeTime = function (anum, cnum, isa, isr) { 128 | if (isr) { 129 | global.timer.change(1); 130 | return; 131 | } 132 | if (!global.timer) { 133 | return; 134 | } 135 | var result; 136 | if (!anum && !cnum) { 137 | var t = prompt("输入欲改变计时器变化倍率(当前:" + 1 / timerContext._percentage + ")"); 138 | if (t == null) { 139 | return; 140 | } 141 | if (isNaN(parseFloat(t))) { 142 | alert("请输入正确的数字"); 143 | timer.changeTime(); 144 | return; 145 | } 146 | if (parseFloat(t) <= 0) { 147 | alert("倍率不能小于等于0"); 148 | timer.changeTime(); 149 | return; 150 | } 151 | result = 1 / parseFloat(t); 152 | } else { 153 | if (isa && anum) { 154 | if (1 / timerContext._percentage <= 1 && anum < 0) { 155 | return; 156 | } 157 | result = 1 / (1 / timerContext._percentage + anum); 158 | } else { 159 | if (cnum <= 0) { 160 | cnum = 1 / -cnum 161 | } 162 | result = 1 / ((1 / timerContext._percentage) * cnum); 163 | } 164 | } 165 | timer.change(result); 166 | }; 167 | global.changeTime = timer.changeTime; 168 | }, 169 | applyHooking: function () { 170 | var _this = this; 171 | // 劫持循环计时器 172 | eHookContext.hookReplace(window, 'setInterval', function (setInterval) { 173 | return _this.getHookedTimerFunction('interval', setInterval); 174 | }); 175 | // 劫持单次计时 176 | eHookContext.hookReplace(window, 'setTimeout', function (setTimeout) { 177 | return _this.getHookedTimerFunction('timeout', setTimeout) 178 | }); 179 | // 劫持循环计时器的清除方法 180 | eHookContext.hookBefore(window, 'clearInterval', function (method, args) { 181 | _this.redirectNewestId(args); 182 | }); 183 | // 劫持循环计时器的清除方法 184 | eHookContext.hookBefore(window, 'clearTimeout', function (method, args) { 185 | _this.redirectNewestId(args); 186 | }); 187 | var newFunc = this.getHookedDateConstructor(); 188 | eHookContext.hookClass(window, 'Date', newFunc, '_innerDate', ['now']); 189 | Date.now = function () { 190 | return new Date().getTime(); 191 | }; 192 | eHookContext.hookedToString(timerContext._Date.now, Date.now); 193 | var objToString = Object.prototype.toString; 194 | 195 | Object.prototype.toString = function toString() { 196 | 'use strict'; 197 | if (this instanceof timerContext._mDate) { 198 | return '[object Date]'; 199 | } else { 200 | return objToString.call(this); 201 | } 202 | }; 203 | 204 | eHookContext.hookedToString(objToString, Object.prototype.toString); 205 | eHookContext.hookedToString(timerContext._setInterval, setInterval); 206 | eHookContext.hookedToString(timerContext._setTimeout, setTimeout); 207 | eHookContext.hookedToString(timerContext._clearInterval, clearInterval); 208 | timerContext._mDate = window.Date; 209 | this.hookShadowRoot(); 210 | }, 211 | getHookedDateConstructor: function () { 212 | return function () { 213 | if (arguments.length === 1) { 214 | Object.defineProperty(this, '_innerDate', { 215 | configurable: false, 216 | enumerable: false, 217 | value: new timerContext._Date(arguments[0]), 218 | writable: false 219 | }); 220 | return; 221 | } else if (arguments.length > 1) { 222 | var definedValue; 223 | switch (arguments.length) { 224 | case 2: 225 | definedValue = new timerContext._Date( 226 | arguments[0], 227 | arguments[1] 228 | ); 229 | break; 230 | case 3: 231 | definedValue = new timerContext._Date( 232 | arguments[0], 233 | arguments[1], 234 | arguments[2], 235 | ); 236 | break; 237 | case 4: 238 | definedValue = new timerContext._Date( 239 | arguments[0], 240 | arguments[1], 241 | arguments[2], 242 | arguments[3], 243 | ); 244 | break; 245 | case 5: 246 | definedValue = new timerContext._Date( 247 | arguments[0], 248 | arguments[1], 249 | arguments[2], 250 | arguments[3], 251 | arguments[4] 252 | ); 253 | break; 254 | case 6: 255 | definedValue = new timerContext._Date( 256 | arguments[0], 257 | arguments[1], 258 | arguments[2], 259 | arguments[3], 260 | arguments[4], 261 | arguments[5] 262 | ); 263 | break; 264 | default: 265 | case 7: 266 | definedValue = new timerContext._Date( 267 | arguments[0], 268 | arguments[1], 269 | arguments[2], 270 | arguments[3], 271 | arguments[4], 272 | arguments[5], 273 | arguments[6] 274 | ); 275 | break; 276 | } 277 | 278 | Object.defineProperty(this, '_innerDate', { 279 | configurable: false, 280 | enumerable: false, 281 | value: definedValue, 282 | writable: false 283 | }); 284 | return; 285 | } 286 | var now = timerContext._Date.now(); 287 | var passTime = now - timerContext.__lastDatetime; 288 | var hookPassTime = passTime * (1 / timerContext._percentage); 289 | // console.log(__this.__lastDatetime + hookPassTime, now,__this.__lastDatetime + hookPassTime - now); 290 | Object.defineProperty(this, '_innerDate', { 291 | configurable: false, 292 | enumerable: false, 293 | value: new timerContext._Date(timerContext.__lastMDatetime + hookPassTime), 294 | writable: false 295 | }); 296 | }; 297 | }, 298 | getHookedTimerFunction: function (type, timer) { 299 | var property = '_' + type + 'Ids'; 300 | return function () { 301 | var uniqueId = timerContext.genUniqueId(); 302 | var callback = arguments[0]; 303 | if (typeof callback === 'string') { 304 | callback += ';timer.notifyExec(' + uniqueId + ')'; 305 | arguments[0] = callback; 306 | } 307 | if (typeof callback === 'function') { 308 | arguments[0] = function () { 309 | var returnValue = callback.apply(this, arguments); 310 | timerContext.notifyExec(uniqueId); 311 | return returnValue; 312 | } 313 | } 314 | // 储存原始时间间隔 315 | var originMS = arguments[1]; 316 | // 获取变速时间间隔 317 | arguments[1] *= timerContext._percentage; 318 | var resultId = timer.apply(window, arguments); 319 | // 保存每次使用计时器得到的id以及参数等 320 | timerContext[property][resultId] = { 321 | args: arguments, 322 | originMS: originMS, 323 | originId: resultId, 324 | nowId: resultId, 325 | uniqueId: uniqueId, 326 | oldPercentage: timerContext._percentage, 327 | exceptNextFireTime: timerContext._Date.now() + originMS 328 | }; 329 | return resultId; 330 | }; 331 | }, 332 | redirectNewestId: function (args) { 333 | var id = args[0]; 334 | if (timerContext._intervalIds[id]) { 335 | args[0] = timerContext._intervalIds[id].nowId; 336 | // 清除该记录id 337 | delete timerContext._intervalIds[id]; 338 | } 339 | if (timerContext._timeoutIds[id]) { 340 | args[0] = timerContext._timeoutIds[id].nowId; 341 | // 清除该记录id 342 | delete timerContext._timeoutIds[id]; 343 | } 344 | }, 345 | registerShortcutKeys: function (timer) { 346 | // 快捷键注册 347 | addEventListener('keydown', function (e) { 348 | switch (e.keyCode) { 349 | case 57: 350 | if (e.ctrlKey || e.altKey) { 351 | // custom 352 | timer.changeTime(); 353 | } 354 | break; 355 | // [=] 356 | case 190: 357 | case 187: { 358 | if (e.ctrlKey) { 359 | // console.log('+2'); 360 | timer.changeTime(2, 0, true); 361 | } else if (e.altKey) { 362 | // console.log('xx2'); 363 | timer.changeTime(0, 2); 364 | } 365 | break; 366 | } 367 | // [-] 368 | case 188: 369 | case 189: { 370 | if (e.ctrlKey) { 371 | // console.log('-2'); 372 | timer.changeTime(-2, 0, true); 373 | } else if (e.altKey) { 374 | // console.log('xx-2'); 375 | timer.changeTime(0, -2); 376 | } 377 | break; 378 | } 379 | // [0] 380 | case 48: { 381 | if (e.ctrlKey || e.altKey) { 382 | // console.log('reset'); 383 | timer.changeTime(0, 0, false, true); 384 | } 385 | break; 386 | } 387 | default: 388 | // console.log(e); 389 | } 390 | }); 391 | }, 392 | /** 393 | * 当计时器速率被改变时调用的回调方法 394 | * @param percentage 395 | * @private 396 | */ 397 | percentageChangeHandler: function (percentage) { 398 | // 改变所有的循环计时 399 | util.ergodicObject(timerContext, timerContext._intervalIds, function (idObj, id) { 400 | idObj.args[1] = Math.floor((idObj.originMS || 1) * percentage); 401 | // 结束原来的计时器 402 | this._clearInterval.call(window, idObj.nowId); 403 | // 新开一个计时器 404 | idObj.nowId = this._setInterval.apply(window, idObj.args); 405 | }); 406 | // 改变所有的延时计时 407 | util.ergodicObject(timerContext, timerContext._timeoutIds, function (idObj, id) { 408 | var now = this._Date.now(); 409 | var exceptTime = idObj.exceptNextFireTime; 410 | var oldPercentage = idObj.oldPercentage; 411 | var time = exceptTime - now; 412 | if (time < 0) { 413 | time = 0; 414 | } 415 | var changedTime = Math.floor(percentage / oldPercentage * time); 416 | idObj.args[1] = changedTime; 417 | // 重定下次执行时间 418 | idObj.exceptNextFireTime = now + changedTime; 419 | idObj.oldPercentage = percentage; 420 | // 结束原来的计时器 421 | this._clearTimeout.call(window, idObj.nowId); 422 | // 新开一个计时器 423 | idObj.nowId = this._setTimeout.apply(window, idObj.args); 424 | }); 425 | }, 426 | hookShadowRoot: function () { 427 | var origin = Element.prototype.attachShadow; 428 | eHookContext.hookAfter(Element.prototype, 'attachShadow', 429 | function (m, args, result) { 430 | extraElements.push(result); 431 | return result; 432 | }, false); 433 | eHookContext.hookedToString(origin, Element.prototype.attachShadow); 434 | }, 435 | hookDefine: function () { 436 | const _this = this; 437 | eHookContext.hookBefore(Object, 'defineProperty', function (m, args) { 438 | var option = args[2]; 439 | var ele = args[0]; 440 | var key = args[1]; 441 | var afterArgs = _this.hookDefineDetails(ele, key, option); 442 | afterArgs.forEach((arg, i) => { 443 | args[i] = arg; 444 | }) 445 | }); 446 | eHookContext.hookBefore(Object, 'defineProperties', function (m, args) { 447 | var option = args[1]; 448 | var ele = args[0]; 449 | if (ele && ele instanceof Element) { 450 | Object.keys(option).forEach(key => { 451 | var o = option[key]; 452 | var afterArgs = _this.hookDefineDetails(ele, key, o); 453 | args[0] = afterArgs[0]; 454 | delete option[key]; 455 | option[afterArgs[1]] = afterArgs[2] 456 | }) 457 | } 458 | }) 459 | }, 460 | hookDefineDetails: function (target, key, option) { 461 | if (option && target && target instanceof Element && typeof key === 'string' && key.indexOf('on') >= 0) { 462 | option.configurable = true; 463 | } 464 | if (target instanceof HTMLVideoElement && key === 'playbackRate') { 465 | option.configurable = true; 466 | console.warn('[Timer Hook]', '已阻止默认操作视频倍率'); 467 | key = 'playbackRate_hooked' 468 | } 469 | return [target, key, option]; 470 | }, 471 | suppressEvent: function (ele, eventName) { 472 | if (ele) { 473 | delete ele['on' + eventName]; 474 | delete ele['on' + eventName]; 475 | delete ele['on' + eventName]; 476 | ele['on' + eventName] = undefined; 477 | } 478 | if (!suppressEvents[eventName]) { 479 | eHookContext.hookBefore(EventTarget.prototype, 'addEventListener', 480 | function (m, args) { 481 | var eName = args[0]; 482 | if (eventName === eName) { 483 | console.warn(eventName, 'event suppressed.') 484 | args[0] += 'suppressed'; 485 | } 486 | }, false); 487 | suppressEvents[eventName] = true; 488 | } 489 | }, 490 | changePlaybackRate: function (ele, rate) { 491 | delete ele.playbackRate; 492 | delete ele.playbackRate; 493 | delete ele.playbackRate; 494 | ele.playbackRate = rate 495 | if (rate !== 1) { 496 | timerContext.defineProperty.call(Object, ele, 'playbackRate', { 497 | configurable: true, 498 | get: function () { 499 | return 1; 500 | }, 501 | set: function () { 502 | } 503 | }); 504 | } 505 | } 506 | } 507 | }; 508 | 509 | var normalUtil = { 510 | isInIframe: function () { 511 | let is = global.parent !== global; 512 | try { 513 | is = is && global.parent.document.body.tagName !== 'FRAMESET' 514 | } catch (e) { 515 | // ignore 516 | } 517 | return is; 518 | }, 519 | listenParentEvent: function (handler) { 520 | global.addEventListener('message', function (e) { 521 | var data = e.data; 522 | var type = data.type || ''; 523 | if (type === 'changePercentage') { 524 | handler(data.percentage || 0); 525 | } 526 | }) 527 | }, 528 | sentChangesToIframe: function (percentage) { 529 | var iframes = document.querySelectorAll('iframe') || []; 530 | var frames = document.querySelectorAll('frame'); 531 | if (iframes.length) { 532 | for (var i = 0; i < iframes.length; i++) { 533 | iframes[i].contentWindow.postMessage( 534 | {type: 'changePercentage', percentage: percentage}, '*'); 535 | } 536 | } 537 | if (frames.length) { 538 | for (var j = 0; j < frames.length; j++) { 539 | frames[j].contentWindow.postMessage( 540 | {type: 'changePercentage', percentage: percentage}, '*'); 541 | } 542 | } 543 | } 544 | }; 545 | 546 | var querySelectorAll = function (ele, selector, includeExtra) { 547 | var elements = ele.querySelectorAll(selector); 548 | elements = Array.prototype.slice.call(elements || []); 549 | if (includeExtra) { 550 | extraElements.forEach(function (element) { 551 | elements = elements.concat(querySelectorAll(element, selector, false)); 552 | }) 553 | } 554 | return elements; 555 | }; 556 | 557 | var generate = function () { 558 | return function (util) { 559 | // disable worker 560 | workerURLs.forEach(function (url) { 561 | if (util.urlMatching(location.href, 'http.*://.*' + url + '.*')) { 562 | window['Worker'] = undefined; 563 | console.log('Worker disabled'); 564 | } 565 | }); 566 | var eHookContext = this; 567 | var timerHooker = { 568 | // 用于储存计时器的id和参数 569 | _intervalIds: {}, 570 | _timeoutIds: {}, 571 | _auoUniqueId: 1, 572 | // 计时器速率 573 | __percentage: 1.0, 574 | // 劫持前的原始的方法 575 | _setInterval: window['setInterval'], 576 | _clearInterval: window['clearInterval'], 577 | _clearTimeout: window['clearTimeout'], 578 | _setTimeout: window['setTimeout'], 579 | _Date: window['Date'], 580 | __lastDatetime: new Date().getTime(), 581 | __lastMDatetime: new Date().getTime(), 582 | videoSpeedInterval: 1000, 583 | defineProperty: Object.defineProperty, 584 | defineProperties: Object.defineProperties, 585 | genUniqueId: function () { 586 | return this._auoUniqueId++; 587 | }, 588 | notifyExec: function (uniqueId) { 589 | var _this = this; 590 | if (uniqueId) { 591 | // 清除 timeout 所储存的记录 592 | var timeoutInfos = Object.values(this._timeoutIds).filter( 593 | function (info) { 594 | return info.uniqueId === uniqueId; 595 | } 596 | ); 597 | timeoutInfos.forEach(function (info) { 598 | _this._clearTimeout.call(window, info.nowId); 599 | delete _this._timeoutIds[info.originId] 600 | }) 601 | } 602 | // console.log(uniqueId, 'called') 603 | }, 604 | /** 605 | * 初始化方法 606 | */ 607 | init: function () { 608 | var timerContext = this; 609 | var h = helper(eHookContext, timerContext, util); 610 | 611 | h.hookDefine(); 612 | h.applyHooking(); 613 | 614 | // 设定百分比属性被修改的回调 615 | Object.defineProperty(timerContext, '_percentage', { 616 | get: function () { 617 | return timerContext.__percentage; 618 | }, 619 | set: function (percentage) { 620 | if (percentage === timerContext.__percentage) { 621 | return percentage; 622 | } 623 | h.percentageChangeHandler(percentage); 624 | timerContext.__percentage = percentage; 625 | return percentage; 626 | } 627 | }); 628 | 629 | if (!normalUtil.isInIframe()) { 630 | console.log('[TimeHooker]', 'loading outer window...'); 631 | h.applyUI(); 632 | h.applyGlobalAction(timerContext); 633 | h.registerShortcutKeys(timerContext); 634 | } else { 635 | console.log('[TimeHooker]', 'loading inner window...'); 636 | normalUtil.listenParentEvent((function (percentage) { 637 | console.log('[TimeHooker]', 'Inner Changed', percentage) 638 | this.change(percentage); 639 | }).bind(this)) 640 | } 641 | }, 642 | /** 643 | * 调用该方法改变计时器速率 644 | * @param percentage 645 | */ 646 | change: function (percentage) { 647 | this.__lastMDatetime = this._mDate.now(); 648 | this.__lastDatetime = this._Date.now(); 649 | this._percentage = percentage; 650 | var oldNode = document.getElementsByClassName('_th-click-hover'); 651 | var oldNode1 = document.getElementsByClassName('_th_times'); 652 | var displayNum = (1 / this._percentage).toFixed(2); 653 | (oldNode[0] || {}).innerHTML = 'x' + displayNum; 654 | (oldNode1[0] || {}).innerHTML = 'x' + displayNum; 655 | var a = document.getElementsByClassName('_th_cover-all-show-times')[0] || {}; 656 | a.className = '_th_cover-all-show-times'; 657 | this._setTimeout.bind(window)(function () { 658 | a.className = '_th_cover-all-show-times _th_hidden'; 659 | }, 100); 660 | this.changeVideoSpeed(); 661 | normalUtil.sentChangesToIframe(percentage); 662 | }, 663 | changeVideoSpeed: function () { 664 | var timerContext = this; 665 | var h = helper(eHookContext, timerContext, util); 666 | var rate = 1 / this._percentage; 667 | rate > 16 && (rate = 16); 668 | rate < 0.065 && (rate = 0.065); 669 | var videos = querySelectorAll(document, 'video', true) || []; 670 | if (videos.length) { 671 | for (var i = 0; i < videos.length; i++) { 672 | h.changePlaybackRate(videos[i], rate); 673 | } 674 | } 675 | } 676 | }; 677 | // 默认初始化 678 | timerHooker.init(); 679 | return timerHooker; 680 | } 681 | }; 682 | 683 | if (global.eHook) { 684 | global.eHook.plugins({ 685 | name: 'timer', 686 | /** 687 | * 插件装载 688 | * @param util 689 | */ 690 | mount: generate() 691 | }); 692 | } 693 | }(window); -------------------------------------------------------------------------------- /src/plugins/wenku2word/readme.md: -------------------------------------------------------------------------------- 1 | # 百度文库转 Word / PDF | 免费下载百度文库文章 [![gitee.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNTQyMTMwNzVXcWZyU2dTbC5wbmc=&w=20)](https://gitee.com/HGJing/everthing-hook/tree/master/src/plugins/wenku2word "Gitee") [![github.png](https://palerock.cn/api-provider/files/view?identity=L2FydGljbGUvaW1hZ2UvMjAyMDA2MjkxNjU3NDkzMDkybWNLRXhHMi5wbmc=&w=20)](https://github.com/canguser/hooker-js/tree/master/src/plugins/wenku2word "Github") 2 | 3 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/views-info/405373) 4 | ![Daily Installs](https://palerock.cn/node-service/images/greasyfork/stats/daily-installs/405373) 5 | ![Daily Updates](https://palerock.cn/node-service/images/greasyfork/stats/daily-updates/405373) 6 | ![Total Installs](https://palerock.cn/node-service/images/greasyfork/stats/total-installs/405373) 7 | 8 |

暂时不可用,维护中!

9 | 10 | 不同于其它的文库下载器,该插件原理是使用脚本将文库的文本内容找到并整理格式最后转换为 word / PDF 下载,使用该脚本不会将页面跳转到其它网址,也不会有任何收费选项,只需要等待解析完成即可,**如有问题请多多反馈** 11 | 12 | 使用方法如下: 13 | 14 | 1. 安装: [GreasyFork](https://greasyfork.org/scripts/405373) 15 | 2. 进入指定文库页面 16 | 3. 等待页面加载完毕 17 | 4. 在下载按钮中找到「文库转 Word / PDF 」按钮 (如最后图所示) 18 | 5. 点击按钮后根据提示等待下载 19 | 20 | 注意事项 21 | 22 | - 转 Word 时 23 | 1. 目前只支持转换文字内容 24 | 2. 目前只支持没有阅读限制的文章(只要没有阅读限制,无论是用券、VIP或付费文章都能下载) 25 | 26 | - 转 PDF 时 27 | 1. 可以转换图片,格式会大幅度保留 28 | 2. 但是转换后的 PDF 内容不能复制 29 | 30 | > 提示: 不能通过转 Word 下载 PPT 或者图片,如果为空文档,检查该文档是否全是图片 31 | 32 | 更新日志 33 | 34 | - 2022-01-27 [0.0.7] 修改部分文字表达 35 | - 2022-01-27 [0.0.6] 支持转换 PDF 功能啦 36 | - 2022-01-21 [0.0.5] 修复文档页面由于使用 canvas 导致的无法提取文字的问题 37 | - 2021-08-24 [0.0.4] 修复某些文库链接插件没有加载的问题 38 | - 2021-05-24 [0.0.3] 修复文库更新后按钮样式再度不显示的问题 39 | - 2021-01-25 [0.0.2] 修复文库更新后按钮样式不显示的问题 40 | - 2020-06-15 [0.0.1] 公测第一版,包含基础功能 -------------------------------------------------------------------------------- /src/plugins/wenku2word/wenku2word.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 百度文库转 Word | 百度文库下载器 3 | // @namespace https://gitee.com/HGJing/everthing-hook/ 4 | // @version 0.0.7 5 | // @description [暂时不可用,维护中!]将百度文库内文章中的文本内容转换为 word / pdf 并下载,仅支持没有阅读限制的文章(只要没有阅读限制,无论是用券、VIP或付费文章都能下载) 6 | // @require https://cdn.bootcss.com/jquery/2.2.4/jquery.js 7 | // @require https://greasyfork.org/scripts/405376-filesaver-html5/code/FileSaver(html5).js?version=816426 8 | // @require https://greasyfork.org/scripts/372672-everything-hook/code/Everything-Hook.js?version=784972 9 | // @author Cangshi 10 | // @match *://wenku.baidu.com/view* 11 | // @match *://wenku.baidu.com/link* 12 | // @match *://wenku.baidu.com/share* 13 | // @run-at document-start 14 | // @grant none 15 | // ==/UserScript== 16 | 17 | function wait(ms) { 18 | return new Promise(resolve => { 19 | setTimeout(() => { 20 | resolve(); 21 | }, ms); 22 | }) 23 | } 24 | 25 | 26 | if (typeof jQuery !== "undefined" && typeof saveAs !== "undefined") { 27 | (function ($) { 28 | ~function (global) { 29 | 'use strict'; 30 | if (global.eHook) { 31 | global.eHook.plugins({ 32 | name: 'wenku2word', 33 | /** 34 | * 插件装载 35 | * @param util 36 | */ 37 | mount: function (util) { 38 | this.hookBefore(Element.prototype, 'removeChild', 39 | function (m, args) { 40 | var ele = args[0]; 41 | if (ele && ele.classList && ele.classList.contains('reader-parent')) { 42 | var instead = document.createElement('div'); 43 | this.appendChild(instead); 44 | args[0] = instead; 45 | } 46 | }, false); 47 | return { 48 | wordExport: function (elements, fileName) { 49 | fileName = typeof fileName !== 'undefined' ? fileName : document.title; 50 | var constant = { 51 | wordHtml: { 52 | top: "Mime-Version: 1.0\nContent-Base: " + location.href + "\nContent-Type: Multipart/related; boundary=\"NEXT.ITEM-BOUNDARY\";type=\"text/html\"\n\n--NEXT.ITEM-BOUNDARY\nContent-Type: text/html; charset=\"utf-8\"\nContent-Location: " + location.href + "\n\n\n\n_html_", 53 | head: "\n\n\n\n", 54 | body: "_body_" 55 | } 56 | }; 57 | var markup = $(elements).clone(); 58 | 59 | markup.each(function () { 60 | var self = $(this); 61 | if (self.is(':hidden')) 62 | self.remove(); 63 | }); 64 | 65 | var htmlEnd = "\n"; 66 | htmlEnd += "--NEXT.ITEM-BOUNDARY--"; 67 | 68 | var fileContent = constant.wordHtml.top.replace("_html_", constant.wordHtml.head.replace("_styles_", '') + constant.wordHtml.body.replace("_body_", markup.text().split('\n').map(t => `

${t}

`).join(''))) + htmlEnd; 69 | 70 | var blob = new Blob([fileContent], { 71 | type: "application/msword;charset=utf-8" 72 | }); 73 | saveAs(blob, fileName + ".doc"); 74 | }, 75 | doExport: function () { 76 | this.wordExport($(".reader-word-layer")); 77 | }, 78 | isLoaded: false, 79 | fetchMoreContent() { 80 | var goNext = document.querySelector('.goBtn') || document.querySelector('.read-all'); 81 | let elem = document.documentElement; 82 | let elem2 = document.body; 83 | let totalHeight = elem.scrollHeight; 84 | let scrollTop = elem.scrollTop || elem2.scrollTop; 85 | let clientHeight = elem.clientHeight; 86 | 87 | var _this = this; 88 | if (totalHeight - scrollTop <= clientHeight * 1.1 || this.isLoaded) { 89 | this.isLoaded = true; 90 | return Promise.resolve(); 91 | } 92 | if ($(goNext).is(':hidden') || !goNext) { 93 | return wait(200).then( 94 | function () { 95 | window.scroll(0, scrollTop + clientHeight / 4); 96 | return _this.fetchMoreContent(); 97 | } 98 | ); 99 | } 100 | goNext && goNext.click(); 101 | return wait(2000).then( 102 | function () { 103 | return _this.fetchMoreContent(); 104 | } 105 | ); 106 | }, 107 | linksShare: function (){ 108 | var currentLocation = location.href.split('?')[0]; 109 | location.href = currentLocation.replace('/link/', '/share/') 110 | .replace('/view/', '/share/') 111 | .replace('.html', '') + '?share_api=1&width=800' 112 | }, 113 | genShadowBG(){ 114 | if (this.wrapper){ 115 | return this.wrapper; 116 | } 117 | var wrapper = document.createElement('div'); 118 | wrapper.classList.add('shadow-bg'); 119 | wrapper.setAttribute('style','position: fixed; bottom: 0; right: 0; left: 0; top: 0; z-index: 9999; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; flex-direction: column;'); 120 | this.wrapper = wrapper; 121 | return wrapper; 122 | }, 123 | addShareDownloadButton: function (){ 124 | const button = document.createElement('button'); 125 | const wrapper = this.genShadowBG(); 126 | button.innerText = '点击下载该文库文档为 word 格式'; 127 | button.setAttribute('style', 'top: 10px; right: 10px; z-index: 9999; border: 2px solid #fff; padding: 10px; background: #fff; border-radius: 5px; cursor: pointer; color: #fff; font-size: 16px;background: transparent;'); 128 | wrapper.appendChild(button); 129 | const p = document.createElement('p'); 130 | p.setAttribute('style', 'color: #fff; font-size: 12px; margin-top: 10px; margin-bottom: 10px;'); 131 | p.innerText = '需要等待背景加载出文字后才能下载...'; 132 | wrapper.appendChild(p); 133 | const _this = this; 134 | window.addEventListener('load', function () { 135 | document.body.appendChild(wrapper); 136 | button.addEventListener('click', function () { 137 | button.setAttribute('disabled', 'disabled'); 138 | button.style.color = '#ccc'; 139 | button.style.cursor = 'not-allowed'; 140 | p.innerText = '正在下载...'; 141 | window.scroll(0,0) 142 | _this.fetchMoreContent() 143 | .then(function (){ 144 | p.innerText = '下载完成,请在浏览器下载内容中查看'; 145 | _this.doExport(); 146 | }) 147 | }); 148 | }); 149 | }, 150 | addPdfDownloadButton:function (){ 151 | this.importScript('https://unpkg.com/jspdf@2.5.0/dist/jspdf.umd.js') 152 | this.importScript('https://unpkg.com/html2canvas@1.4.1/dist/html2canvas.min.js') 153 | const wrapper = this.genShadowBG(); 154 | const button = document.createElement('button'); 155 | button.innerText = '点击下载该文库文档为 PDF 格式'; 156 | button.setAttribute('style', 'top: 10px; right: 10px; z-index: 9999; border: 2px solid #fff; padding: 10px; background: #fff; border-radius: 5px; cursor: pointer; color: #fff; font-size: 16px;background: transparent;'); 157 | wrapper.appendChild(button); 158 | const p = document.createElement('p'); 159 | p.setAttribute('style', 'color: #fff; font-size: 12px; margin-top: 10px;'); 160 | p.innerText = 'PDF 为图片内容,且仅支持少量文档(不建议使用)...'; 161 | wrapper.appendChild(p); 162 | const _this = this; 163 | window.addEventListener('load', function () { 164 | document.body.appendChild(wrapper); 165 | button.addEventListener('click', function () { 166 | button.setAttribute('disabled', 'disabled'); 167 | button.style.color = '#ccc'; 168 | button.style.cursor = 'not-allowed'; 169 | p.innerText = '正在下载中...'; 170 | window.scroll(0,0) 171 | _this.fetchMoreContent() 172 | .then(function (){ 173 | p.innerText = '正在转换格式中...'; 174 | _this.doExportPdf() 175 | .then(function (){ 176 | p.innerText = '下载完成,请在浏览器下载内容中查看'; 177 | }); 178 | }) 179 | }); 180 | }); 181 | }, 182 | doExportPdf: function () { 183 | var pages = document.querySelectorAll('.reader-page') 184 | var pdf = new window.jspdf.jsPDF('', 'pt', 'a4'); 185 | var promises = []; 186 | for (var i = 0; i < pages.length; i++) { 187 | promises.push(window.html2canvas(pages[i])) 188 | } 189 | return Promise.all(promises) 190 | .then(canvasList=>{ 191 | for (var i = 0; i< canvasList.length; i++){ 192 | var canvas = canvasList[i]; 193 | var imgData = canvas.toDataURL('image/jpeg', 1.0); 194 | pdf.addImage(imgData, 'JPEG', 0, 0, 595.28, 592.28/canvas.width * canvas.height ); 195 | if (i < canvasList.length - 1) { 196 | pdf.addPage(); 197 | } 198 | } 199 | pdf.save('文库文档.pdf'); 200 | }) 201 | }, 202 | importScript: function (url){ 203 | var script = document.createElement('script'); 204 | script.src = url; 205 | document.body.appendChild(script); 206 | } 207 | } 208 | } 209 | }); 210 | } 211 | }(window); 212 | console.log('wenku2word loaded successfully'); 213 | if (/^.*wenku\.baidu\.com\/share\/.*/.test(location.href)) { 214 | window.wenku2word.addShareDownloadButton(); 215 | window.wenku2word.addPdfDownloadButton(); 216 | } 217 | window.addEventListener('load', function () { 218 | 219 | var existBtn = $('.core-btn-wrapper > div'); 220 | if (!existBtn || !existBtn.length) { 221 | return; 222 | } 223 | 224 | var btn = $('
') 225 | 226 | if (existBtn) { 227 | btn = existBtn.clone(); 228 | } 229 | 230 | btn[0].className = 'btn-download btn-pay reader-download'; 231 | 232 | btn[0].innerHTML = '文库转 Word / PDF '; 233 | 234 | btn[0].style.marginLeft = '10px'; 235 | 236 | btn.click(function (e) { 237 | e.preventDefault(); 238 | e.stopPropagation(); 239 | window.wenku2word.linksShare(); 240 | /* 241 | window.scroll(0, 0); 242 | var spinner = document.createElement('div'); 243 | spinner.innerText = '解析文章中, 请稍候...'; 244 | spinner.style.position = 'fixed'; 245 | spinner.style.width = '100%'; 246 | spinner.style.height = '100%'; 247 | spinner.style.textAlign = 'center'; 248 | spinner.style.paddingTop = '10rem'; 249 | spinner.style.backgroundColor = 'rgba(255,255,255,.8)'; 250 | spinner.style.zIndex = '99999'; 251 | spinner.style.fontSize = '3rem'; 252 | spinner.style.top = '0'; 253 | spinner.style.left = '0'; 254 | document.body.appendChild(spinner); 255 | window.wenku2word.fetchMoreContent() 256 | .then(function () { 257 | spinner.innerText = '解析成功, 即将下载...'; 258 | return wait(2000) 259 | }).then(function () { 260 | window.wenku2word.doExport(); 261 | document.body.removeChild(spinner); 262 | } 263 | ); 264 | */ 265 | }); 266 | 267 | $('.toolbar-core-btns-wrap').append(btn[0]); 268 | $('.core-btn-wrapper').append(btn[0]); 269 | console.log('button added'); 270 | }) 271 | })(jQuery); 272 | } else { 273 | console.log('wenku2word loaded failed'); 274 | } 275 | 276 | 277 | 278 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = env => { 4 | return { 5 | mode: env.production === 'true' ? 'production' : 'none', 6 | //entry:需要打包的文件 7 | entry: './src/hooker.js', 8 | output: { 9 | // filename:指定打包后js文件的名字 10 | filename: env.production === 'true' ? 'hooker-mini.js' : 'hooker.js', 11 | //path:指定打包后的文件放在那里 12 | path: path.resolve(__dirname, "build"), 13 | libraryTarget: "umd", 14 | globalObject: "typeof self !== 'undefined' ? self : this" 15 | } 16 | } 17 | }; --------------------------------------------------------------------------------