This commit is contained in:
cilame 2022-03-23 23:08:14 +08:00
parent 86eb180b13
commit 47a6f23593
4 changed files with 40 additions and 3 deletions

View File

@ -904,7 +904,7 @@ function injectfunc(e, window) {
var toggle = true
if (e["config-hook-alt-w"]) {
document.onkeydown = function(event){
document.onkeydown = e.logtogglefunc = function(event){
if (event.key == 'w' && event.altKey){
toggle = !toggle
e["config-hook-domobj"] = toggle
@ -1317,6 +1317,9 @@ chrome.extension.onMessage.addListener(function(msg, sender, sendResponse) {
inject_script(`console.error(${JSON.stringify(msg.action.info)})`)
}
if (msg.action.type == 'addlistener'){
inject_script(`v_log_env()`)
inject_script(`try{v_log_env()}catch(e){debugger;alert('请打开调试总开关同时将dom挂钩全部选中后再刷新页面点击代码生成按钮。')}`)
}
if (msg.action.type == 'logtoggle'){
inject_script(`globalConfig.logtogglefunc({key:'w',altKey:true})`)
}
});

View File

@ -44,6 +44,7 @@
"page": "background.html",
"persistent": true
},
"devtools_page": "devtools.html",
"content_scripts": [
{
"matches": [ "file:///*", "http://*/*", "https://*/*" ],

View File

@ -87,6 +87,32 @@
opacity: 1;
right: 0;
}
.button2 {
display: inline-block;
padding: 10px;
font-size: 15px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
width: 160px;
transition: all 0.5s;
margin: 5px;
color: #fff;
background-color: #f4511e;
border: none;
border-radius: 4px;
box-shadow: 0 3px #999;
}
.button2:hover {background-color: #b62f04}
.button2:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
</style>
</head>
@ -97,7 +123,8 @@
<div style="float: right; padding: 10px">是否挂钩总开关</div>
<div>
<button id="showoptions" class="button" style="vertical-align:middle"><span>打开配置页面</span></button>
<button id="addlistener" class="button" style="vertical-align:middle"><span>生成临时环境</span></button>
<button id="addlistener" class="button2" style="vertical-align:middle"><span>生成临时环境</span></button>
<button id="logtoggle" class="button2" style="vertical-align:middle"><span>开关输出日志</span></button>
</div>
<script src="popup.js"></script>
</body>

View File

@ -37,4 +37,10 @@ document.getElementById('addlistener').addEventListener('click', function(e){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'addlistener', info: 'addlistener'}}, function(response) {});
});
})
document.getElementById('logtoggle').addEventListener('click', function(e){
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: {type:'logtoggle', info: 'logtoggle'}}, function(response) {});
});
})