mirror of
https://github.com/tidys/cc-inspector-chrome
synced 2025-04-18 07:58:40 +00:00
调整devtools
This commit is contained in:
parent
b0ceb078b9
commit
e5b61e8676
@ -40,3 +40,6 @@ QQ群**224756137**
|
||||
### manifest.json
|
||||
// 开发参考:http://open.chrome.360.cn/extension_dev/overview.html
|
||||
// 字段说明参考:http://open.chrome.360.cn/extension_dev/manifest.html
|
||||
|
||||
## 配合使用插件
|
||||
[extensions-reloader](https://chrome.google.com/webstore/detail/extensions-reloader/fimgfedafeadlieiabdeeaodndnlbhid?utm_source=chrome-ntp-icon)
|
||||
|
@ -1,21 +0,0 @@
|
||||
window.addEventListener('message', function (event) {
|
||||
let data = event.data;
|
||||
// console.log("[contentScripts] " + JSON.stringify(data));
|
||||
chrome.extension.sendMessage(data);
|
||||
}, false);
|
||||
|
||||
|
||||
let gameCanvas = document.querySelector("#GameCanvas");
|
||||
if (gameCanvas) {
|
||||
// console.log('find GameCanvas element');
|
||||
// gameCanvas.addEventListener('click', function () {
|
||||
// console.log("click canvas");
|
||||
// });
|
||||
// gameCanvas.style.display = 'none';
|
||||
} else {
|
||||
// console.log("can't find GameCanvas element");
|
||||
chrome.extension.sendMessage({type: 0, msg: "no creator game!"});
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
// 具有操作dom的能力
|
||||
// 加载其他脚本
|
||||
// var content = chrome.extension.getURL('js/inject.js')
|
||||
// var script = document.createElement('script')
|
||||
// script.setAttribute('type', 'text/javascript')
|
||||
// script.setAttribute('src', content)
|
||||
// script.onload = function () {
|
||||
// // 注入脚本执行完后移除掉
|
||||
// this.parentNode.removeChild(this);
|
||||
// }
|
||||
// document.body.appendChild(script)
|
||||
|
||||
|
||||
|
||||
window.addEventListener('message', function (event) {
|
||||
let data = event.data;
|
||||
// console.log("[contentScripts] " + JSON.stringify(data));
|
||||
chrome.runtime.sendMessage(data);
|
||||
}, false);
|
||||
|
||||
|
||||
let gameCanvas = document.querySelector("#GameCanvas");
|
||||
if (gameCanvas) {
|
||||
// console.log('find GameCanvas element');
|
||||
// gameCanvas.addEventListener('click', function () {
|
||||
// console.log("click canvas");
|
||||
// });
|
||||
// gameCanvas.style.display = 'none';
|
||||
} else {
|
||||
// console.log("can't find GameCanvas element");
|
||||
chrome.runtime.sendMessage({type: 0, msg: "no creator game!"});
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Dev</title>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
@ -1,52 +0,0 @@
|
||||
// 检查游戏是否为cocos游戏
|
||||
// var cc={};
|
||||
// if (typeof cc === "undefined") {
|
||||
// console.log("该html不是cocos游戏,无法调试!");
|
||||
// chrome.devtools.panels.elements.createSidebarPane("Creator Properties", function (sidebar) {
|
||||
// // console.log("[Cocos Creator Inspector] CreateSidebarPane");
|
||||
// // sidebar.setObject({ some_data: "Some data to show" });
|
||||
// sidebar.setPage("devNoGame.html");
|
||||
// });
|
||||
// chrome.devtools.panels.create(
|
||||
// "Cocos",
|
||||
// "static/images/icon48.png",
|
||||
// "devNoGame.html", function (panel) {
|
||||
// // console.log("[Cocos Creator Inspector] Dev Panel Created!");
|
||||
// });
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
chrome.devtools.panels.elements.createSidebarPane('My SliderBar', function (sidebar) {
|
||||
sidebar.setObject({some_data: "some data to show!"});
|
||||
});
|
||||
|
||||
chrome.devtools.panels.create(
|
||||
"Cocos",
|
||||
"static/images/icon48.png",
|
||||
"devInspector.html",
|
||||
function (panel) {
|
||||
console.log("[Cocos Creator Inspector] Dev Panel Created!");
|
||||
|
||||
panel.onShown.addListener(function (window) {
|
||||
console.log("panel show");
|
||||
});
|
||||
panel.onHidden.addListener(function (window) {
|
||||
console.log("panel hide");
|
||||
});
|
||||
panel.onSearch.addListener(function (action, query) {
|
||||
console.log("panel search!");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// (function () {
|
||||
// var t = window.setInterval(function () {
|
||||
// egret && egret.devtool &&
|
||||
// egret.devtool.start &&
|
||||
// (window.clearInterval(t) || egret.devtool.start());
|
||||
// console.log("waiting")
|
||||
// }, 100);
|
||||
// egret && egret.devtool && egret.devtool.start && (window.clearInterval(t) || egret.devtool.start());
|
||||
// })();
|
12
CocosCreatorInspector/src/devtools/dev_panel.js
Normal file
12
CocosCreatorInspector/src/devtools/dev_panel.js
Normal file
@ -0,0 +1,12 @@
|
||||
import Vue from 'vue';
|
||||
import dev_panel from './dev_panel.vue';
|
||||
|
||||
import ElementUI from 'element-ui'
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
Vue.use(ElementUI);
|
||||
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(dev_panel)
|
||||
});
|
20
CocosCreatorInspector/src/devtools/dev_panel.vue
Normal file
20
CocosCreatorInspector/src/devtools/dev_panel.vue
Normal file
@ -0,0 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-button @click="onClick">devtools</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "index",
|
||||
methods: {
|
||||
onClick() {
|
||||
console.log("devtools");
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,51 @@
|
||||
// 检查游戏是否为cocos游戏
|
||||
// var cc={};
|
||||
// if (typeof cc === "undefined") {
|
||||
// console.log("该html不是cocos游戏,无法调试!");
|
||||
// chrome.devtools.panels.elements.createSidebarPane("Creator Properties", function (sidebar) {
|
||||
// // console.log("[Cocos Creator Inspector] CreateSidebarPane");
|
||||
// // sidebar.setObject({ some_data: "Some data to show" });
|
||||
// sidebar.setPage("devNoGame.html");
|
||||
// });
|
||||
// chrome.devtools.panels.create(
|
||||
// "Cocos",
|
||||
// "static/images/icon48.png",
|
||||
// "devNoGame.html", function (panel) {
|
||||
// // console.log("[Cocos Creator Inspector] Dev Panel Created!");
|
||||
// });
|
||||
//
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
// chrome.devtools.panels.elements.createSidebarPane('My SliderBar', function (sidebar) {
|
||||
// sidebar.setObject({some_data: "some data to show!"});
|
||||
// });
|
||||
|
||||
chrome.devtools.panels.create("Cocos", "icon/icon48.png", "pages/dev_panel.html",
|
||||
function (panel) {
|
||||
console.log("[Cocos Creator Inspector] Dev Panel Created!");
|
||||
|
||||
panel.onShown.addListener(function (window) {
|
||||
console.log("panel show");
|
||||
});
|
||||
panel.onHidden.addListener(function (window) {
|
||||
console.log("panel hide");
|
||||
});
|
||||
panel.onSearch.addListener(function (action, query) {
|
||||
console.log("panel search!");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// (function () {
|
||||
// var t = window.setInterval(function () {
|
||||
// egret && egret.devtool &&
|
||||
// egret.devtool.start &&
|
||||
// (window.clearInterval(t) || egret.devtool.start());
|
||||
// console.log("waiting")
|
||||
// }, 100);
|
||||
// egret && egret.devtool && egret.devtool.start && (window.clearInterval(t) || egret.devtool.start());
|
||||
// })();
|
@ -13,13 +13,10 @@ module.exports = {
|
||||
devtools_page: "pages/devtools.html",
|
||||
content_scripts: [
|
||||
{
|
||||
matches: [
|
||||
"<all_urls>"
|
||||
],
|
||||
js: [
|
||||
"js/content.js"
|
||||
],
|
||||
run_at: "document_end"
|
||||
matches: ["<all_urls>"],
|
||||
js: ["js/content.js"],
|
||||
run_at: "document_end",
|
||||
all_frames: true
|
||||
}
|
||||
],
|
||||
background: {
|
||||
|
@ -31,6 +31,7 @@ module.exports = {
|
||||
entry: {
|
||||
popup: resolve("popup"),
|
||||
devtools: resolve("devtools"),
|
||||
dev_panel:resolve("devtools/dev_panel"),
|
||||
background: resolve("background"),
|
||||
options: resolve('options'),
|
||||
content: resolve("content"),
|
||||
@ -60,6 +61,7 @@ module.exports = {
|
||||
|
||||
htmlPage("popup", 'popup', ['popup']),
|
||||
htmlPage("devtools", 'devtools', ['devtools']),
|
||||
htmlPage("dev_panel", 'dev_panel', ['dev_panel']),
|
||||
htmlPage("options", 'options', ['options']),
|
||||
htmlPage('background', 'background', ['background']),
|
||||
new ChromeManifest({
|
||||
|
Loading…
x
Reference in New Issue
Block a user