简体   繁体   English

将Safari扩展程序修改为主页中的iframe

[英]Safari extension modifying to an iframe within main page

Hi I've wrote simple Safari extension to display QR code with url to currently visiting website..This is part of code where I am appending the code to page.. 嗨,我编写了一个简单的Safari扩展程序,以显示带有当前访问网站URL的QR代码。这是我将代码附加到页面的代码的一部分。

document.body.insertBefore(qrdisplay, document.body.firstChild);
   qrdisplay.appendChild(img);

All is wokring, but what sucks is, the code appends too to an iframe content..Actually nasty problem if every site contains facebook like box and lot of other crap:D Can I somehow append the element only to main body?When I would use some kind of "body child of body" selector it wouldnt work..It simply cant as there are two independent DOMs?Am I right? 一切都令人不安,但糟糕的是,代码也将添加到iframe内容上..如果每个站点都包含类似box之类的facebook和许多其他废话,那实际上是一个讨厌的问题:D我能以某种方式仅将元素添加到主体吗?使用某种“ body body of body”选择器将无法正常工作。它根本无法运行,因为有两个独立的DOM?对吗?

Thanks for your advice, I hope you understand to my problem.. 感谢您的建议,希望您能理解我的问题。

我认为您需要在运行附加代码之前检查window === window.top

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM