This commit is contained in:
cilame 2022-09-29 01:34:19 +08:00
parent e31a7ad4c7
commit 3c0cb35d08
4 changed files with 21 additions and 13 deletions

View File

@ -266,10 +266,10 @@ function get_html(url){
for (var i = 0; i < keys.length; i++) {
if (json[keys[i]].type == 'Script' && used_script.indexOf(keys[i]) == -1){
console.log('not find script...', keys[i], json[keys[i]].data.length)
json_obj[keys[i]] = json[keys[i]]
json_obj[keys[i]] = {}
json_obj[keys[i]].type = json[keys[i]].type
json_obj[keys[i]].func = `vilame_run${i}`
func_str += script_escape(`vilame_json['vilame_run${i}'] = function (){${json_obj[keys[i]].data}}`) + '\n'
delete json_obj[keys[i]].data
}
}
var insert_code = `

View File

@ -1716,14 +1716,6 @@ chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) {
if (msg.action.type == 'logtoggle'){
inject_script(`globalConfig.logtogglefunc({key:'w',altKey:true})`)
}
if (msg.action.type == 'clone_page'){
var data = msg.action.info
if (data.status == 'ok'){
inject_script(`(function(str){const el=document.createElement("textarea");el.value=str;el.setAttribute("readonly","");el.style.position="absolute";el.style.left="-9999px";document.body.appendChild(el);const selected=document.getSelection().rangeCount>0?document.getSelection().getRangeAt(0):false;el.select();document.execCommand("copy");document.body.removeChild(el);if(selected){document.getSelection().removeAllRanges();document.getSelection().addRange(selected)}})(${JSON.stringify(data.info)});alert('html内容已经拷贝到剪贴板')`)
}else{
inject_script(`alert('获取html结构失败请右键需要拷贝的页面的空白处选择“打开 v_jstools 动态调试”。刷新页面后,确保页面资源加载充足后再重新点击“拷贝当前页面”')`)
}
}
if (msg.action.type == 'alerterror'){
inject_script(`alert(${JSON.stringify(msg.action.info)})`)
}

View File

@ -35,7 +35,19 @@
"name": "v_jstools",
"version": "0.0.0",
"description": "v_jstools js hook工具",
"permissions": ["storage", "unlimitedStorage", "activeTab", "tabs", "debugger", "storage", "contextMenus", "http://*/*", "https://*/*", "cookies", "proxy"],
"permissions": ["storage",
"unlimitedStorage",
"activeTab",
"tabs",
"debugger",
"storage",
"contextMenus",
"http://*/*",
"https://*/*",
"cookies",
"downloads",
"proxy"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"browser_action": {
"default_popup": "popup.html"

View File

@ -67,9 +67,13 @@ document.getElementById('clone_page').addEventListener('click', function(e){
var url = tabs[0].url
var html = bg.get_html(url)
if (html){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'clone_page', info: {status: 'ok', info: html}}}, function(response) {});
var url = URL.createObjectURL(new Blob(html.split(''), {type: 'text/html'}))
chrome.downloads.download({
url: url,
filename: 'clone_html.html'
});
}else{
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'clone_page', info: {status: 'error', info: html}}}, function(response) {});
alert('获取html结构失败请右键需要拷贝的页面的空白处选择“打开 v_jstools 动态调试”。刷新页面后,确保页面资源加载充足后再重新点击“拷贝当前页面”')
}
});
})