mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-17 23:08:33 +02:00
Add examples of differen window types (#217)
This commit is contained in:
@@ -13,16 +13,21 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a href="#" id="window-update-size_768">Resize window to 768x1024</a><br>
|
<a href="#" id="window-update-size_768">Resize window to 768x1024</a><br>
|
||||||
|
<a href="#" id="window-resize-all">Resize all windows to 1024x768</a><br>
|
||||||
<a href="#" id="window-update-minimize">Minimize</a><br>
|
<a href="#" id="window-update-minimize">Minimize</a><br>
|
||||||
|
|
||||||
<div class="panel-section-separator"></div>
|
<div class="panel-section-separator"></div>
|
||||||
|
|
||||||
<a href="#" id="window-create-incognito">Create new incognito window</a><br>
|
<a href="#" id="window-create-incognito">Create new incognito window</a><br>
|
||||||
<a href="#" id="window-remove">Remove active window</a><br>
|
<a href="#" id="window-create-normal">Create normal window</a><br>
|
||||||
|
<a href="#" id="window-create-panel">Create panel</a><br>
|
||||||
|
<a href="#" id="window-create-detached-panel">Create detached panel</a><br>
|
||||||
|
<a href="#" id="window-create-popup">Create popup</a><br>
|
||||||
|
|
||||||
<div class="panel-section-separator"></div>
|
<div class="panel-section-separator"></div>
|
||||||
|
|
||||||
<a href="#" id="window-resize-all">Resize all windows to 1024x768</a><br>
|
<a href="#" id="window-remove">Remove active window</a><br>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="window.js"></script>
|
<script src="window.js"></script>
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ document.addEventListener("click", (e) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (e.target.id === "window-create-normal") {
|
||||||
|
var createData = {};
|
||||||
|
var creating = browser.windows.create(createData);
|
||||||
|
creating.then(() => {
|
||||||
|
console.log("The normal window has been created");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
else if (e.target.id === "window-create-incognito") {
|
else if (e.target.id === "window-create-incognito") {
|
||||||
var createData = {
|
var createData = {
|
||||||
incognito: true,
|
incognito: true,
|
||||||
@@ -35,6 +43,36 @@ document.addEventListener("click", (e) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (e.target.id === "window-create-panel") {
|
||||||
|
var createData = {
|
||||||
|
type: "panel",
|
||||||
|
};
|
||||||
|
var creating = browser.windows.create(createData);
|
||||||
|
creating.then(() => {
|
||||||
|
console.log("The panel has been created");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (e.target.id === "window-create-detached-panel") {
|
||||||
|
var createData = {
|
||||||
|
type: "detached_panel",
|
||||||
|
};
|
||||||
|
var creating = browser.windows.create(createData);
|
||||||
|
creating.then(() => {
|
||||||
|
console.log("The detached panel has been created");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (e.target.id === "window-create-popup") {
|
||||||
|
var createData = {
|
||||||
|
type: "popup",
|
||||||
|
};
|
||||||
|
var creating = browser.windows.create(createData);
|
||||||
|
creating.then(() => {
|
||||||
|
console.log("The popup has been created");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
else if (e.target.id === "window-remove") {
|
else if (e.target.id === "window-remove") {
|
||||||
getCurrentWindow().then((currentWindow) => {
|
getCurrentWindow().then((currentWindow) => {
|
||||||
browser.windows.remove(currentWindow.id);
|
browser.windows.remove(currentWindow.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user