博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
浏览器插件 - 通用注入模版JS
阅读量:6862 次
发布时间:2019-06-26

本文共 2057 字,大约阅读时间需要 6 分钟。

//TIP:先通过Tampermonkey编写为可用脚本,再套用此通用模版,再拖到Chrome安装为扩展即可。

/* 通用注入原型3:*/

switch (window.location.pathname){    case "???":        inject(YeScript.newFunc);        break;}function inject(func){    if (typeof (func) != 'function')        return;    YEJS = "//================== [YEJS START] =======================\n(";    YEJS += func;    YEJS += ")();";    YEJS += "\n//================== [YEJS ENDED] =======================";    script = document.createElement('script');    script.type = 'text/javascript';    script.id = 'YEJS';    script.innerHTML = YEJS;    var scriptTag = document.getElementById('YEJS');    if (scriptTag) document.body.removeChild(scriptTag);    document.body.appendChild(script);}

 

/* 通用注入原型2:*/

var reallyJs = (function YeDoIt(){//通过将实际的待注入网页的脚本写到这里即可。}.toString());YEJS = "//================== [YEJS START] =======================\n";YEJS += reallyJs;YEJS += "\nYeDoIt();";YEJS += "\n//================== [YEJS ENDED] =======================";script = document.createElement('script');script.id = 'YEJS';script.type = 'text/javascript';script.innerHTML = YEJS;var scriptTag = document.getElementById('YEJS');if (scriptTag) document.body.removeChild(scriptTag);document.body.appendChild(script);

  

/* 通用注入原型1:*/

var YEJS="\//================== [YEJS START] =======================\n\将要注入的JS:1.需要替换所有[双引号]为[单引号] 或\"引号!2.需要替换所有\n为\\n\\\n3.不留空行或空行也要用\n\符号代替!4.将正则表达式中的\d\w等改为\\d\\w才有效!\n//================== [YEJS ENDED] =======================";//======================================================// 直接注入JS到网页中,可自由操纵原网页的任何脚本!//======================================================script = document.createElement('script');script.type = 'text/javascript';script.id = 'YEJS';script.innerHTML = YEJS;var scriptTag = document.getElementById('YEJS');if (scriptTag) document.body.removeChild(scriptTag);document.body.appendChild(script);//======================================================// 插件的JS与原网页的JS唯一的交流通道为网页DOM树!//======================================================

  

转载于:https://www.cnblogs.com/AsionTang/p/3442081.html

你可能感兴趣的文章
本地通知,UILocalNotification
查看>>
分页---总结
查看>>
前端开发的历史和趋势(转摘阮一峰)
查看>>
Ubuntu 削减非 LTS 支持周期
查看>>
_实用的cms企业后台管理模板
查看>>
菜鸟看Redis(一)
查看>>
matplotlib.pyplot.plot()参数详解
查看>>
||PHP||关于=>和->以及::的用法
查看>>
最短路径问题
查看>>
Yii2中定义自己的Widget
查看>>
Aforge.net识别简易数字验证码问题
查看>>
JVM系列二:GC策略&内存申请、对象衰老
查看>>
MySQL 数据库备份策略:全备与增量备份
查看>>
Springboot的热部署
查看>>
Thinking in UML-1-为什么需要UML
查看>>
vs编译obj给delphi用
查看>>
过游戏保护NP或TP的几种方法和思路
查看>>
equals和hashcode为什么要一起重写
查看>>
模态与非模态对话框的问题
查看>>
地对地导弹地对地导弹地对地导弹
查看>>