diff --git a/background.js b/background.js index 3ca346c..9a8f74c 100644 --- a/background.js +++ b/background.js @@ -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 = ` diff --git a/inject.js b/inject.js index 51e0b95..f295c5d 100644 --- a/inject.js +++ b/inject.js @@ -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)})`) } diff --git a/manifest.json b/manifest.json index 15502dc..f9e2670 100644 --- a/manifest.json +++ b/manifest.json @@ -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" diff --git a/popup.js b/popup.js index 9ba23a5..604b0f8 100644 --- a/popup.js +++ b/popup.js @@ -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 动态调试”。刷新页面后,确保页面资源加载充足后再重新点击“拷贝当前页面”') } }); }) \ No newline at end of file