Skip to content

Commit

Permalink
修改sandbox iframe 判断
Browse files Browse the repository at this point in the history
save changed

save changed

change sandbox html

format js html code
  • Loading branch information
jingjingxyk committed Jan 13, 2023
1 parent 4ff7540 commit ae47d29
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 9 deletions.
27 changes: 22 additions & 5 deletions extension/sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,42 @@
<meta charset="UTF-8" />
<title>测试地址</title>
<style>
body {
background-color: #292929;
}

li {
text-decoration: none;
list-style: disc;
color: #31c27c;
font-size: 1.2rem;
font-size: 1.4rem;
line-height: 2.2rem;
}

li pre {
cursor: pointer;
}
li:hover {

a {
color: #31c27c;
color: #30ba78;
}

h3 {
color: #c5955d;
}

li:hover,
a:hover {
color: #c5955d;
/*
transform: scale(1.2);
*/
transform: scale(1.2);
*/
}
</style>
</head>
<body>
<h3>演示例子:浏览chromium、webRTC源码</h3>
<h3>演示例子:</h3>
<ul class="box"></ul>
<script src="js/app.js"></script>
</body>
Expand Down
24 changes: 20 additions & 4 deletions extension/sandbox/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* 完善本扩展的初衷,获取知识
* @type {string[]}
*/
let preview_url = [
"https://source.chromium.org/",
"https://summerofcode.withgoogle.com/programs/2022/organizations",
Expand All @@ -6,7 +10,6 @@ let preview_url = [
"https://chromium.googlesource.com/external/webrtc",
"https://cs.opensource.google/",
"https://www.kernel.org/",
"https://fuchsia.googlesource.com/",
"https://android.googlesource.com/",
"https://www.freertos.org/",
"https://ffmpeg.org/",
Expand All @@ -20,11 +23,24 @@ let preview_url = [
"https://home.uniontech.com/",
"http://www.wangma.net.cn/",
"https://www.cncf.io/",
"https://github.com/riscv",
"https://docs.ros.org/",
];

let is_iframe = self !== top;
let list_box = document.querySelector(".box");
let list = "";
preview_url.map((value, index) => {
list += `<li data-href="${value}" ><pre>${value}</pre></li>`;
if (is_iframe) {
list += `<li data-href="${value}" ><pre>${value}</pre></li>`;
} else {
list += `<li data-href="${value}" >
<a
target="_blank"
rel="noopener noreferrer"
href="${value}"
>${value}</a></li>`;
}
});
list_box.innerHTML = list;

Expand All @@ -33,8 +49,8 @@ list_box.addEventListener("click", (event) => {
//console.log(event.target.nodeName);
if (event.target.nodeName === "PRE") {
let url = event.target.innerText;
console.log(self, top);
if (self !== top) {
//console.log(self, top);
if (is_iframe) {
//'在iframe中'
console.log("在iframe中");
window.parent.postMessage(
Expand Down

0 comments on commit ae47d29

Please sign in to comment.