简体   繁体   English

如何为我的谷歌扩展程序关闭 popup.html?

[英]How to close popup.html for my google extension?

How can I visibly hide my popup.html whenever I click a button on that popup.每当我单击该弹出窗口上的按钮时,如何才能明显隐藏我的 popup.html。 I want to keep my scripts running but minimize the popup off the page.我想让我的脚本继续运行,但尽量减少页面上的弹出窗口。 The reason i'm doing this is because i'm making an eye dropper extension that can get the color under your cursor and perhaps that color is being blocked by the popup hence why I want to get hide it when I'm looking for a color.我这样做的原因是因为我正在做一个滴管扩展,它可以在你的 cursor 下获得颜色,也许那个颜色被弹出窗口阻止了,因此为什么我想在我寻找一个时隐藏它颜色。 Once I've picked my color the popup reappears.一旦我选择了我的颜色,弹出窗口就会重新出现。

You'll have to resize the popup eg by hiding everything inside.您必须调整弹出窗口的大小,例如将所有内容隐藏在里面。 The minimum size is still 16x16.最小尺寸仍然是 16x16。

popup.js should call start() inside some event listener: popup.js 应该在某个事件侦听器中调用start()

function start() {
  Object.assign(document.documentElement, {
    className: 'hidden',
    title: 'Click to cancel',
    onclick: stop,
  });
}
function stop() {
  Object.assign(document.documentElement, {
    className: '',
    title: '',
    onclick: null,
  });
}

popup.css:弹出窗口.css:

html.hidden * {
  display: none !important
}

html.hidden::after {
  content: 'x';
  text-align: center;
  display: block;
  cursor: pointer;
}

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

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