├── .gitignore ├── demo ├── npm-test.js ├── aHook-testing.html ├── demo-hook-class.html ├── dome-hook-jquery.html ├── aHook-testing-2.html ├── hooking-ajax.html ├── aHook-testing-4.html ├── lib │ └── ajax.js └── aHook-testing-3.html ├── webpack.config.js ├── package.json ├── src ├── plugins │ ├── copying-lifted │ │ ├── readme.md │ │ ├── copyingLifted.js │ │ └── LICENSE │ ├── wenku2word │ │ ├── readme.md │ │ └── wenku2word.js │ ├── timer-hooker │ │ ├── readme.md │ │ ├── time-hooker-style.html │ │ ├── LICENSE │ │ └── timeHooker.js │ └── hookAll.js └── hooker.js ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | node_modules 3 | out -------------------------------------------------------------------------------- /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', '?'); -------------------------------------------------------------------------------- /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 | }; -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /demo/aHook-testing-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | AHook Testing 2 11 | 12 | 13 | 14 | 24 | 25 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /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] 公测第一版,包含基础功能 -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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); -------------------------------------------------------------------------------- /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`,然后通过 `