mirror of
https://git.mirrors.martin98.com/https://github.com/cilame/v_jstools
synced 2025-08-15 13:15:58 +08:00
add
This commit is contained in:
parent
03afd61d74
commit
1d5b1cded1
@ -24,9 +24,41 @@ function add_hook_event_code(tabs, callback){
|
|||||||
var toggle = true
|
var toggle = true
|
||||||
var elelist = []
|
var elelist = []
|
||||||
var v_stringify = JSON.stringify
|
var v_stringify = JSON.stringify
|
||||||
|
var v_parse = JSON.parse
|
||||||
function log_ele(name, e){
|
function log_ele(name, e){
|
||||||
if (toggle){
|
if (toggle){
|
||||||
elelist.push([name, e, v_stringify({type:name, x: e.clientX, y: e.clientY, screenX: e.screenX, screenY: e.screenY, timeStamp: e.timeStamp})])
|
if (!e.target.tagName){
|
||||||
|
var css = ''
|
||||||
|
}else{
|
||||||
|
var css = e.target.tagName.toLowerCase()
|
||||||
|
+ (e.target.id ? '#' + e.target.id : '')
|
||||||
|
+ (e.target.classList.length ? '.' + e.target.classList[0] : '')
|
||||||
|
}
|
||||||
|
function tofixnum(dict, num){
|
||||||
|
num = num || 1
|
||||||
|
var keys = Object.keys(v_parse(v_stringify(dict)))
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
if (typeof dict[keys[i]] == 'number'){
|
||||||
|
dict[keys[i]] = +dict[keys[i]].toFixed(num)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dict
|
||||||
|
}
|
||||||
|
elelist.push([name, e,
|
||||||
|
v_stringify({
|
||||||
|
type:name,
|
||||||
|
x: e.clientX,
|
||||||
|
y: e.clientY,
|
||||||
|
screenX: e.screenX,
|
||||||
|
screenY: e.screenY,
|
||||||
|
timeStamp: e.timeStamp,
|
||||||
|
css: {
|
||||||
|
selector: css,
|
||||||
|
rect: tofixnum(e.target.getBoundingClientRect ? e.target.getBoundingClientRect() : {}),
|
||||||
|
tagName: e.target.tagName || undefined,
|
||||||
|
id: e.target.id || undefined,
|
||||||
|
},
|
||||||
|
})])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function copyToClipboard(str, maxtime){
|
function copyToClipboard(str, maxtime){
|
||||||
|
166
inject.js
166
inject.js
@ -310,10 +310,22 @@ function make_v(envs, keys){
|
|||||||
HTMLAnchorElement:{
|
HTMLAnchorElement:{
|
||||||
__init__:{
|
__init__:{
|
||||||
value: `v_hook_href(this, 'HTMLAnchorElement', location.href)`
|
value: `v_hook_href(this, 'HTMLAnchorElement', location.href)`
|
||||||
}
|
},
|
||||||
|
href: { ban: true },
|
||||||
|
protocol: { ban: true },
|
||||||
|
host: { ban: true },
|
||||||
|
search: { ban: true },
|
||||||
|
hash: { ban: true },
|
||||||
|
hostname: { ban: true },
|
||||||
|
port: { ban: true },
|
||||||
|
pathname: { ban: true },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
var avoid_obj = ['URL']
|
||||||
function make_chain(name){
|
function make_chain(name){
|
||||||
|
if (avoid_obj.indexOf(name) != -1){
|
||||||
|
return []
|
||||||
|
}
|
||||||
var _name = name
|
var _name = name
|
||||||
var list = []
|
var list = []
|
||||||
if (window[_name]){
|
if (window[_name]){
|
||||||
@ -621,6 +633,7 @@ function make_v(envs, keys){
|
|||||||
v_new_htmlmap[v_eles[i]] = htmlmap[v_eles[i]]
|
v_new_htmlmap[v_eles[i]] = htmlmap[v_eles[i]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
v_new_htmlmap['HTMLAnchorElement'] = ["a"]; // 确保a标签存在
|
||||||
var v_createE = JSON.stringify(v_new_htmlmap, 0, 0)
|
var v_createE = JSON.stringify(v_new_htmlmap, 0, 0)
|
||||||
var v_cele = []
|
var v_cele = []
|
||||||
if (v_createE.length > 3){
|
if (v_createE.length > 3){
|
||||||
@ -661,12 +674,13 @@ function make_v(envs, keys){
|
|||||||
_global.push(`if (typeof Buffer != 'undefined'){ Buffer = undefined }`)
|
_global.push(`if (typeof Buffer != 'undefined'){ Buffer = undefined }`)
|
||||||
_global.push(`var __globalThis__ = typeof global != 'undefined' ? global : this`)
|
_global.push(`var __globalThis__ = typeof global != 'undefined' ? global : this`)
|
||||||
_global.push(`var window = new Proxy(v_new(Window), {`)
|
_global.push(`var window = new Proxy(v_new(Window), {`)
|
||||||
_global.push(` get(a,b){ return a[b] || __globalThis__[b] },`)
|
_global.push(` get(a,b){ if(b=='global'){return}return a[b] || __globalThis__[b] },`)
|
||||||
_global.push(` set(a,b,c){ `)
|
_global.push(` set(a,b,c){ `)
|
||||||
_global.push(` if (b == 'onclick' && typeof c == 'function') { window.addEventListener('click', c) }`)
|
_global.push(` if (b == 'onclick' && typeof c == 'function') { window.addEventListener('click', c) }`)
|
||||||
_global.push(` if (b == 'onmousedown' && typeof c == 'function') { window.addEventListener('mousedown', c) }`)
|
_global.push(` if (b == 'onmousedown' && typeof c == 'function') { window.addEventListener('mousedown', c) }`)
|
||||||
_global.push(` if (b == 'onmouseup' && typeof c == 'function') { window.addEventListener('mouseup', c) }`)
|
_global.push(` if (b == 'onmouseup' && typeof c == 'function') { window.addEventListener('mouseup', c) }`)
|
||||||
_global.push(` __globalThis__[b] = a[b] = c `)
|
_global.push(` __globalThis__[b] = a[b] = c `)
|
||||||
|
_global.push(` return true `)
|
||||||
_global.push(` },`)
|
_global.push(` },`)
|
||||||
_global.push(`})`)
|
_global.push(`})`)
|
||||||
_global.push(`var v_hasOwnProperty = Object.prototype.hasOwnProperty`)
|
_global.push(`var v_hasOwnProperty = Object.prototype.hasOwnProperty`)
|
||||||
@ -694,6 +708,32 @@ function make_v(envs, keys){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_global.push(`
|
||||||
|
var win = {
|
||||||
|
window: window,
|
||||||
|
frames: window,
|
||||||
|
parent: window,
|
||||||
|
self: window,
|
||||||
|
top: window,
|
||||||
|
}
|
||||||
|
function v_repair_this(){
|
||||||
|
win = {
|
||||||
|
window: __globalThis__,
|
||||||
|
frames: __globalThis__,
|
||||||
|
parent: __globalThis__,
|
||||||
|
self: __globalThis__,
|
||||||
|
top: __globalThis__,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object.defineProperties(window, {
|
||||||
|
window: {get:function(){return win.window},set:function(e){return win.window = e}},
|
||||||
|
frames: {get:function(){return win.frames},set:function(e){return win.frames = e}},
|
||||||
|
parent: {get:function(){return win.parent},set:function(e){return win.parent = e}},
|
||||||
|
self: {get:function(){return win.self}, set:function(e){return win.self = e}},
|
||||||
|
top: {get:function(){return win.top}, set:function(e){return win.top = e}},
|
||||||
|
})
|
||||||
|
`)
|
||||||
|
|
||||||
var tail = [
|
var tail = [
|
||||||
`function init_cookie(cookie){
|
`function init_cookie(cookie){
|
||||||
var cache = (cookie || "").trim();
|
var cache = (cookie || "").trim();
|
||||||
@ -738,10 +778,10 @@ function make_v(envs, keys){
|
|||||||
function v_hook_href(obj, name, initurl){
|
function v_hook_href(obj, name, initurl){
|
||||||
var r = Object.defineProperty(obj, 'href', {
|
var r = Object.defineProperty(obj, 'href', {
|
||||||
get: function(){
|
get: function(){
|
||||||
if (!(this.protocol) && !(this.host)){
|
if (!(this.protocol) && !(this.hostname)){
|
||||||
r = ''
|
r = ''
|
||||||
}else{
|
}else{
|
||||||
r = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "") + this.pathname + this.search + this.hash;
|
r = this.protocol + "//" + this.hostname + (this.port ? ":" + this.port : "") + this.pathname + this.search + this.hash;
|
||||||
}
|
}
|
||||||
v_console_log(\` [*] \${name||obj.constructor.name} -> href[get]:\`, JSON.stringify(r))
|
v_console_log(\` [*] \${name||obj.constructor.name} -> href[get]:\`, JSON.stringify(r))
|
||||||
return r
|
return r
|
||||||
@ -751,16 +791,16 @@ function v_hook_href(obj, name, initurl){
|
|||||||
v_console_log(\` [*] \${name||obj.constructor.name} -> href[set]:\`, JSON.stringify(href))
|
v_console_log(\` [*] \${name||obj.constructor.name} -> href[set]:\`, JSON.stringify(href))
|
||||||
if (href.startsWith("http://") || href.startsWith("https://")){/*ok*/}
|
if (href.startsWith("http://") || href.startsWith("https://")){/*ok*/}
|
||||||
else if(href.startsWith("//")){ href = (this.protocol?this.protocol:'http:') + href}
|
else if(href.startsWith("//")){ href = (this.protocol?this.protocol:'http:') + href}
|
||||||
else{ href = this.protocol+"//"+this.host + (this.port?":"+this.port:"") + '/' + ((href[0]=='/')?href.slice(1):href) }
|
else{ href = this.protocol+"//"+this.hostname + (this.port?":"+this.port:"") + '/' + ((href[0]=='/')?href.slice(1):href) }
|
||||||
var a = href.match(/([^:]+:)\\/\\/([^/:?#]+):?(\\d+)?([^?#]*)?(\\?[^#]*)?(#.*)?/);
|
var a = href.match(/([^:]+:)\\/\\/([^/:?#]+):?(\\d+)?([^?#]*)?(\\?[^#]*)?(#.*)?/);
|
||||||
this.protocol = a[1] ? a[1] : "";
|
this.protocol = a[1] ? a[1] : "";
|
||||||
this.host = a[2] ? a[2] : "";
|
this.hostname = a[2] ? a[2] : "";
|
||||||
this.port = a[3] ? a[3] : "";
|
this.port = a[3] ? a[3] : "";
|
||||||
this.pathname = a[4] ? a[4] : "";
|
this.pathname = a[4] ? a[4] : "";
|
||||||
this.search = a[5] ? a[5] : "";
|
this.search = a[5] ? a[5] : "";
|
||||||
this.hash = a[6] ? a[6] : "";
|
this.hash = a[6] ? a[6] : "";
|
||||||
this.hostname = this.host;
|
this.host = this.hostname + (this.port?":"+this.port:"") ;
|
||||||
this.origin = this.protocol + "//" + this.host + (this.port ? ":" + this.port : "");
|
this.origin = this.protocol + "//" + this.hostname + (this.port ? ":" + this.port : "");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (initurl && initurl.trim()){ var temp=v_new_toggle; v_new_toggle = true; r.href = initurl; v_new_toggle = temp; }
|
if (initurl && initurl.trim()){ var temp=v_new_toggle; v_new_toggle = true; r.href = initurl; v_new_toggle = temp; }
|
||||||
@ -1035,6 +1075,8 @@ window.atob = window.atob || v_saf(atob_btoa.atob, 'atob')
|
|||||||
|
|
||||||
`init_cookie(${JSON.stringify(document.cookie)})`,
|
`init_cookie(${JSON.stringify(document.cookie)})`,
|
||||||
`v_hook_href(window.location, 'location', ${JSON.stringify(location.href)})`,
|
`v_hook_href(window.location, 'location', ${JSON.stringify(location.href)})`,
|
||||||
|
`Location.prototype.toString = v_saf(function toString(){ return ${JSON.stringify(location.href)} })`,
|
||||||
|
`window.alert = v_saf(function alert(){})`,
|
||||||
`v_hook_storage()`,
|
`v_hook_storage()`,
|
||||||
`v_init_document()`,
|
`v_init_document()`,
|
||||||
`v_init_canvas()`,
|
`v_init_canvas()`,
|
||||||
@ -1112,7 +1154,10 @@ window.atob = window.atob || v_saf(atob_btoa.atob, 'atob')
|
|||||||
tail.push(`})();`)
|
tail.push(`})();`)
|
||||||
tail.push(`var v_to_time = +new v_Date`)
|
tail.push(`var v_to_time = +new v_Date`)
|
||||||
tail.push(`// var v_to_time = +new v_Date('Sat Sep 03 2022 11:11:58 GMT+0800') // 自定义起始时间`)
|
tail.push(`// var v_to_time = +new v_Date('Sat Sep 03 2022 11:11:58 GMT+0800') // 自定义起始时间`)
|
||||||
|
tail.push(``)
|
||||||
|
tail.push(`v_repair_this() // 修复 window 指向global`)
|
||||||
tail.push('v_new_toggle = undefined')
|
tail.push('v_new_toggle = undefined')
|
||||||
|
tail.push('// v_console_log = function(){} // 关闭日志输出')
|
||||||
var rets = [
|
var rets = [
|
||||||
`var v_saf;!function(){var n=Function.toString,t=[],i=[],o=[].indexOf.bind(t),e=[].push.bind(t),r=[].push.bind(i);function u(n,t){return-1==o(n)&&(e(n),r(\`function \${t||n.name||""}() { [native code] }\`)),n}Object.defineProperty(Function.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"function"==typeof this&&i[o(this)]||n.call(this)}}),u(Function.prototype.toString,"toString"),v_saf=u}();`,
|
`var v_saf;!function(){var n=Function.toString,t=[],i=[],o=[].indexOf.bind(t),e=[].push.bind(t),r=[].push.bind(i);function u(n,t){return-1==o(n)&&(e(n),r(\`function \${t||n.name||""}() { [native code] }\`)),n}Object.defineProperty(Function.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"function"==typeof this&&i[o(this)]||n.call(this)}}),u(Function.prototype.toString,"toString"),v_saf=u}();`,
|
||||||
'\n',
|
'\n',
|
||||||
@ -1187,7 +1232,34 @@ function injectfunc(e, window) {
|
|||||||
|
|
||||||
var expurl = RegExp((e["config-hook-regexp-url"] || '').trim())
|
var expurl = RegExp((e["config-hook-regexp-url"] || '').trim())
|
||||||
RegExp.prototype.v_test = RegExp.prototype.test
|
RegExp.prototype.v_test = RegExp.prototype.test
|
||||||
String.prototype.v_split = String.prototype.split
|
var c_split = String.prototype.split
|
||||||
|
String.prototype.v_split = function(){
|
||||||
|
if (typeof this == 'string'){
|
||||||
|
return c_split.apply(this, arguments)
|
||||||
|
}else{
|
||||||
|
return 'error v_split'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function openwin(txt) {
|
||||||
|
var OpenWindow = window.open("about:blank", "1", "height=600, width=800,toolbar=no,scrollbars=" + scroll + ",menubar=no");
|
||||||
|
OpenWindow.document.write(`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>从下面的窗口直接复制生成的代码使用</h3>
|
||||||
|
<textarea style="width: 100%; height: 1500px" id="txt" spellcheck="false"></textarea>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
`)
|
||||||
|
var left = 100
|
||||||
|
var top = 100
|
||||||
|
OpenWindow.moveTo(left, top);
|
||||||
|
OpenWindow.document.close()
|
||||||
|
return OpenWindow.txt.value = txt || ''
|
||||||
|
}
|
||||||
|
|
||||||
var v_window_cache = {}
|
var v_window_cache = {}
|
||||||
var v_winkeys = Object.getOwnPropertyNames(window)
|
var v_winkeys = Object.getOwnPropertyNames(window)
|
||||||
@ -1200,24 +1272,28 @@ function injectfunc(e, window) {
|
|||||||
window.v_log_env = function (){
|
window.v_log_env = function (){
|
||||||
$make_v_func
|
$make_v_func
|
||||||
function copyToClipboard(str){
|
function copyToClipboard(str){
|
||||||
const el = document.createElement('textarea');
|
try{
|
||||||
el.value = str;
|
openwin(str)
|
||||||
el.setAttribute('readonly', '');
|
}catch(e){
|
||||||
el.style.position = 'absolute';
|
const el = document.createElement('textarea');
|
||||||
el.style.left = '-9999px';
|
el.value = str;
|
||||||
document.body.appendChild(el);
|
el.setAttribute('readonly', '');
|
||||||
const selected =
|
el.style.position = 'absolute';
|
||||||
document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
|
el.style.left = '-9999px';
|
||||||
el.select();
|
document.body.appendChild(el);
|
||||||
document.execCommand('copy');
|
const selected =
|
||||||
document.body.removeChild(el);
|
document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
|
||||||
if (selected) {
|
el.select();
|
||||||
document.getSelection().removeAllRanges();
|
document.execCommand('copy');
|
||||||
document.getSelection().addRange(selected);
|
document.body.removeChild(el);
|
||||||
alert('已将代码存放到剪贴板中。')
|
if (selected) {
|
||||||
}else{
|
document.getSelection().removeAllRanges();
|
||||||
alert('保存至剪贴板失败。尝试直接将代码用 console.log 直接输出在控制台中。(因为可能会保存失败,可以多点几次 “生成临时环境”)')
|
document.getSelection().addRange(selected);
|
||||||
console.log(str)
|
alert('已将代码存放到剪贴板中。')
|
||||||
|
}else{
|
||||||
|
alert('保存至剪贴板失败。尝试直接将代码用 console.log 直接输出在控制台中。(因为可能会保存失败,可以多点几次 “生成临时环境”)')
|
||||||
|
console.log(str)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var mkstr = make_v([v_env_cache, v_getelement_all])
|
var mkstr = make_v([v_env_cache, v_getelement_all])
|
||||||
@ -1776,11 +1852,47 @@ chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) {
|
|||||||
if (msg.action.type == 'alerterror'){
|
if (msg.action.type == 'alerterror'){
|
||||||
inject_script(`alert(${JSON.stringify(msg.action.info)})`)
|
inject_script(`alert(${JSON.stringify(msg.action.info)})`)
|
||||||
}
|
}
|
||||||
|
if (msg.action.type == 'run_in_page'){
|
||||||
|
inject_script(`${msg.action.info}`)
|
||||||
|
}
|
||||||
if (msg.action.type == 'getcookie'){
|
if (msg.action.type == 'getcookie'){
|
||||||
// 有些 onlyhttp 的 cookie 直接通过 js 拿不到,所以这个插件会主动在 js 环境下注入一个 vilame_setter 参数。
|
// 有些 onlyhttp 的 cookie 直接通过 js 拿不到,所以这个插件会主动在 js 环境下注入一个 vilame_setter 参数。
|
||||||
// 通过 vilame_setter 参数可以直接拿到所有当前页面 domain 下的 cookie 包括 httponly 类型的 cookie。
|
// 通过 vilame_setter 参数可以直接拿到所有当前页面 domain 下的 cookie 包括 httponly 类型的 cookie。
|
||||||
inject_script('window.vilame_setter='+JSON.stringify(msg.action.info))
|
inject_script('window.vilame_setter='+JSON.stringify(msg.action.info))
|
||||||
}
|
}
|
||||||
|
if (msg.action.type == 'eval'){
|
||||||
|
var jscode = msg.action.info
|
||||||
|
jscode = `
|
||||||
|
${jscode}
|
||||||
|
var envstr = (function(txt){
|
||||||
|
txt = txt.split('http://pls_init_href_first/test1/test2').join(location.href)
|
||||||
|
txt = txt.split('// $$$referrer').join('document[_y].referrer = "' + (document.referrer || '') + '"')
|
||||||
|
txt = txt.split('// $$$init_cookie').join('window[_y].init_cookie("' + document.cookie + '")')
|
||||||
|
return txt
|
||||||
|
})(window.v_mk())
|
||||||
|
;(function openwin(txt) {
|
||||||
|
var OpenWindow = window.open("about:blank", "1", "height=600, width=800,toolbar=no,scrollbars=" + scroll + ",menubar=no");
|
||||||
|
OpenWindow.document.write(\`
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title></title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h3>从下面的窗口直接复制生成的代码使用</h3>
|
||||||
|
<textarea style="width: 100%; height: 1500px" id="txt" spellcheck="false"></textarea>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
\`)
|
||||||
|
var left = 100
|
||||||
|
var top = 100
|
||||||
|
OpenWindow.moveTo(left, top);
|
||||||
|
OpenWindow.document.close()
|
||||||
|
return OpenWindow.txt.value = txt || ''
|
||||||
|
})(envstr)
|
||||||
|
`
|
||||||
|
inject_script(jscode)
|
||||||
|
}
|
||||||
sendResponse({})
|
sendResponse({})
|
||||||
});
|
});
|
||||||
chrome.extension.sendMessage({getcookie:true, domain:document.domain}, function(res){})
|
chrome.extension.sendMessage({getcookie:true, domain:document.domain}, function(res){})
|
||||||
|
@ -193,6 +193,7 @@
|
|||||||
<button id='babel_aline'>将代码变成一行,不压缩[babel]</button>
|
<button id='babel_aline'>将代码变成一行,不压缩[babel]</button>
|
||||||
<button id='uglify'>仅变量压缩[uglify-es]</button>
|
<button id='uglify'>仅变量压缩[uglify-es]</button>
|
||||||
<button id='uglify_mini'>完全压缩脚本[uglify-es]</button>
|
<button id='uglify_mini'>完全压缩脚本[uglify-es]</button>
|
||||||
|
<button id='terser_mini'>完全压缩脚本[terser]</button>
|
||||||
<button id='open_diff_text'>打开文本对比工具</button>
|
<button id='open_diff_text'>打开文本对比工具</button>
|
||||||
<label id='env' style="color: #FFEEEE">cilame</label>
|
<label id='env' style="color: #FFEEEE">cilame</label>
|
||||||
<br/>
|
<br/>
|
||||||
@ -245,6 +246,9 @@
|
|||||||
<button id="get_code_uglifyjs">uglifyjs模板代码</button>
|
<button id="get_code_uglifyjs">uglifyjs模板代码</button>
|
||||||
<button id="get_code_request">request模板代码</button>
|
<button id="get_code_request">request模板代码</button>
|
||||||
<button id="get_code_jsencrypt">jsencrypt(RSA)模板代码</button>
|
<button id="get_code_jsencrypt">jsencrypt(RSA)模板代码</button>
|
||||||
|
<button id="get_code_cheerio">cheerio模板代码</button>
|
||||||
|
<button id="get_code_terser">terser模板代码</button>
|
||||||
|
<button id="get_code_parse5">parse5模板代码</button>
|
||||||
<br/>
|
<br/>
|
||||||
<hr>
|
<hr>
|
||||||
<label>code</label>
|
<label>code</label>
|
||||||
@ -267,10 +271,12 @@
|
|||||||
<script src="tools/jquery.min.js"></script>
|
<script src="tools/jquery.min.js"></script>
|
||||||
<script src="./tools/common.js"></script>
|
<script src="./tools/common.js"></script>
|
||||||
<script src="./tools/sub_logger.js"></script>
|
<script src="./tools/sub_logger.js"></script>
|
||||||
|
<script src="./tools/_config_hook_list.js"></script>
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
<script src="tools/model_funcs.js"></script>
|
<script src="tools/model_funcs.js"></script>
|
||||||
<script src="tools/babel_asttool.js"></script>
|
<script src="tools/babel_asttool.js"></script>
|
||||||
<script src="tools/uglify_es.js"></script>
|
<script src="tools/uglify_es.js"></script>
|
||||||
|
<script src="tools/terser.js"></script>
|
||||||
<script src="tools/env_maker.js"></script>
|
<script src="tools/env_maker.js"></script>
|
||||||
<script src="tools/btn_utils.js"></script>
|
<script src="tools/btn_utils.js"></script>
|
||||||
<script src="tools/js_obfuscator.js"></script>
|
<script src="tools/js_obfuscator.js"></script>
|
||||||
|
377
options.js
377
options.js
File diff suppressed because one or more lines are too long
@ -146,14 +146,17 @@
|
|||||||
<button id="ast_page" class="button" style="vertical-align:middle"><span>ast工具页面</span></button>
|
<button id="ast_page" class="button" style="vertical-align:middle"><span>ast工具页面</span></button>
|
||||||
<button id="diff_page" class="button" style="vertical-align:middle"><span>文本对比页面</span></button>
|
<button id="diff_page" class="button" style="vertical-align:middle"><span>文本对比页面</span></button>
|
||||||
<button id="addlistener" class="button2" style="vertical-align:middle"><span>生成临时环境</span></button>
|
<button id="addlistener" class="button2" style="vertical-align:middle"><span>生成临时环境</span></button>
|
||||||
|
<button id="create_high_env" class="button2" style="vertical-align:middle"><span>生成高级环境</span></button>
|
||||||
<!-- <button id="logtoggle" class="button2" style="vertical-align:middle"><span>开关输出日志</span></button> -->
|
<!-- <button id="logtoggle" class="button2" style="vertical-align:middle"><span>开关输出日志</span></button> -->
|
||||||
<!-- <button id="clone_page" class="button2" style="vertical-align:middle"><span>拷贝当前页面</span></button> -->
|
<!-- <button id="clone_page" class="button2" style="vertical-align:middle"><span>拷贝当前页面</span></button> -->
|
||||||
<hr>
|
<hr>
|
||||||
<button id="update_page" class="button2" style="vertical-align:middle"><span>工具更新地址</span><br><span>QQ群: 797747562</span></button>
|
<button id="update_page" class="button2" style="vertical-align:middle"><span>工具更新地址</span><br><span>QQ群: 797747562</span></button>
|
||||||
<!-- <div style="padding: 10px">QQ群: 797747562</div> -->
|
<!-- <div style="padding: 10px">QQ群: 797747562</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
<script src="./tools/_config_hook_list.js"></script>
|
||||||
<script src="./tools/common.js"></script>
|
<script src="./tools/common.js"></script>
|
||||||
<script src="./tools/sub_logger.js"></script>
|
<script src="./tools/sub_logger.js"></script>
|
||||||
|
<script src="./tools/mod_code_getter.js"></script>
|
||||||
<script src="popup.js"></script>
|
<script src="popup.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
71
popup.js
71
popup.js
@ -52,19 +52,52 @@ document.getElementById('showoptions').addEventListener('click', function(e){
|
|||||||
})
|
})
|
||||||
|
|
||||||
document.getElementById('addlistener').addEventListener('click', function(e){
|
document.getElementById('addlistener').addEventListener('click', function(e){
|
||||||
chrome.storage.local.get([ "config-hook-domobj", "config-hook-domobj-get", "config-hook-domobj-set", "config-hook-domobj-func" ], function (result) {
|
var check_list = [ "config-hook-global", "config-hook-domobj", "config-hook-domobj-get", "config-hook-domobj-set", "config-hook-domobj-func" ]
|
||||||
if (!(result["config-hook-domobj"] && result["config-hook-domobj-get"] && result["config-hook-domobj-set"] && result["config-hook-domobj-func"])){
|
chrome.storage.local.get(check_list, function (result) {
|
||||||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
if (!(result["config-hook-global"] && result["config-hook-domobj"] && result["config-hook-domobj-get"] && result["config-hook-domobj-set"] && result["config-hook-domobj-func"])){
|
||||||
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'alerterror', info: `请在配置页面中将DOM挂钩功能全部选中。
|
var result = confirm(`
|
||||||
|
启用该功能需要让以下四个配置选中:
|
||||||
|
1: 是否启用挂钩 DOM 对象的原型的功能调试输出
|
||||||
|
2: hook-domobj-显示get输出
|
||||||
|
3: hook-domobj-显示set输出
|
||||||
|
4: hook-domobj-显示func输出
|
||||||
|
|
||||||
以下四个必选:
|
点击 “确认” 会刷新页面并自动选中所需配置,
|
||||||
是否启用挂钩 DOM 对象的原型的功能调试输出
|
然后重新点击 “生成临时环境” 即可生成代码。`);
|
||||||
hook-domobj-显示get输出
|
if(result){
|
||||||
hook-domobj-显示set输出
|
function make_hook(input, name){
|
||||||
hook-domobj-显示func输出
|
var ret = ['config-hook-all-'+name]
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
后面的选项,你也需要全选。`}}, function(response) {});
|
var kv = input[i]
|
||||||
});
|
var k = kv[0]
|
||||||
|
var v = kv[1]
|
||||||
|
ret.push(`config-hook-${k}-${v}`)
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
var all_list = ["config-hook-log-toggle"]
|
||||||
|
.concat(check_list)
|
||||||
|
.concat(make_hook(getsets_0, 'getsets_0'))
|
||||||
|
.concat(make_hook(funcs_0, 'funcs_0'))
|
||||||
|
.concat(make_hook(getsets_1, 'getsets_1'))
|
||||||
|
.concat(make_hook(funcs_1, 'funcs_1'))
|
||||||
|
var config_target = {}
|
||||||
|
for (var i = 0; i < all_list.length; i++) {
|
||||||
|
config_target[all_list[i]] = true
|
||||||
|
}
|
||||||
|
chrome.storage.local.set(config_target, function(e){
|
||||||
|
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||||
|
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'run_in_page', info: `
|
||||||
|
window.open(location, '_self')
|
||||||
|
`}}, function(response) {});
|
||||||
|
});
|
||||||
|
sub_logger()
|
||||||
|
window.close()
|
||||||
|
})
|
||||||
|
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||||
|
// chrome.tabs.sendMessage(tabs[0].id, {action: {type:'alerterror', info: `123123`}}, function(response) {});
|
||||||
|
// });
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||||
@ -73,6 +106,20 @@ hook-domobj-显示func输出
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById('create_high_env').addEventListener('click', function(e){
|
||||||
|
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||||
|
function send(info){
|
||||||
|
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'eval', info: info}}, function(response) {});
|
||||||
|
}
|
||||||
|
get_file("./tools/env_maker.js", send)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
get_file("./tools/env_maker.js", function(){}, function(){
|
||||||
|
document.getElementById('create_high_env').remove()
|
||||||
|
})
|
||||||
|
|
||||||
// document.getElementById('logtoggle').addEventListener('click', function(e){
|
// document.getElementById('logtoggle').addEventListener('click', function(e){
|
||||||
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
|
||||||
// chrome.tabs.sendMessage(tabs[0].id, {action: {type:'logtoggle', info: 'logtoggle'}}, function(response) {});
|
// chrome.tabs.sendMessage(tabs[0].id, {action: {type:'logtoggle', info: 'logtoggle'}}, function(response) {});
|
||||||
|
372
tools/_config_hook_list.js
Normal file
372
tools/_config_hook_list.js
Normal file
File diff suppressed because one or more lines are too long
@ -8,6 +8,7 @@ var obnormalbtn = document.getElementById('obnormal')
|
|||||||
var babel_aline = document.getElementById('babel_aline')
|
var babel_aline = document.getElementById('babel_aline')
|
||||||
var uglifybtn = document.getElementById('uglify')
|
var uglifybtn = document.getElementById('uglify')
|
||||||
var uglify_minibtn = document.getElementById('uglify_mini')
|
var uglify_minibtn = document.getElementById('uglify_mini')
|
||||||
|
var terser_minibtn = document.getElementById('terser_mini')
|
||||||
var txt = document.getElementById('txt')
|
var txt = document.getElementById('txt')
|
||||||
var txt2 = document.getElementById('txt2')
|
var txt2 = document.getElementById('txt2')
|
||||||
|
|
||||||
@ -127,6 +128,12 @@ uglify_minibtn.addEventListener('click', function(e){
|
|||||||
;(txt2||txt).value = r.code?r.code:r.error;
|
;(txt2||txt).value = r.code?r.code:r.error;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
terser_minibtn.addEventListener('click', function(e){
|
||||||
|
terser.minify(txt.value).then(function(e){
|
||||||
|
;(txt2||txt).value = e.code?e.code:e.error;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
var envb = document.getElementById('env');
|
var envb = document.getElementById('env');
|
||||||
envb.addEventListener('dblclick', function(e){
|
envb.addEventListener('dblclick', function(e){
|
||||||
;(txt2||txt).value = '!'+v_mk+'()';
|
;(txt2||txt).value = '!'+v_mk+'()';
|
||||||
|
File diff suppressed because one or more lines are too long
2368
tools/env_maker.js
2368
tools/env_maker.js
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@ function errorHandler(e){
|
|||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_file(filename, callback){
|
function get_file(filename, callback, errcallback){
|
||||||
chrome.runtime.getPackageDirectoryEntry(function(root) {
|
chrome.runtime.getPackageDirectoryEntry(function(root) {
|
||||||
root.getFile(filename, {}, function(fileEntry) {
|
root.getFile(filename, {}, function(fileEntry) {
|
||||||
fileEntry.file(function(file) {
|
fileEntry.file(function(file) {
|
||||||
@ -12,8 +12,8 @@ function get_file(filename, callback){
|
|||||||
callback(this.result)
|
callback(this.result)
|
||||||
}
|
}
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
}, errorHandler);
|
}, (errcallback||errorHandler));
|
||||||
}, errorHandler);
|
}, (errcallback||errorHandler));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,4 +75,34 @@ if (get_code_jsencrypt){
|
|||||||
}
|
}
|
||||||
get_file('tools/jsencrypt.js', callback)
|
get_file('tools/jsencrypt.js', callback)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var get_code_cheerio = document.getElementById('get_code_cheerio')
|
||||||
|
if (get_code_cheerio){
|
||||||
|
get_code_cheerio.addEventListener('click', function(e){
|
||||||
|
function callback(text){
|
||||||
|
document.getElementById('my_code_dec').value = text
|
||||||
|
}
|
||||||
|
get_file('tools/cheerio.js', callback)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var get_code_terser = document.getElementById('get_code_terser')
|
||||||
|
if (get_code_terser){
|
||||||
|
get_code_terser.addEventListener('click', function(e){
|
||||||
|
function callback(text){
|
||||||
|
document.getElementById('my_code_dec').value = text
|
||||||
|
}
|
||||||
|
get_file('tools/terser.js', callback)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var get_code_parse5 = document.getElementById('get_code_parse5')
|
||||||
|
if (get_code_parse5){
|
||||||
|
get_code_parse5.addEventListener('click', function(e){
|
||||||
|
function callback(text){
|
||||||
|
document.getElementById('my_code_dec').value = text
|
||||||
|
}
|
||||||
|
get_file('tools/parse5.js', callback)
|
||||||
|
})
|
||||||
}
|
}
|
19
tools/parse5.js
Normal file
19
tools/parse5.js
Normal file
File diff suppressed because one or more lines are too long
19
tools/terser.js
Normal file
19
tools/terser.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user