Answer the question
In order to leave comments, you need to log in
How to open a page with the current URL as a query in Opera extension popup?
Hello!
I want to write an Opera extension for this one - vPass . I need to open a popup with the current URL as a parameter (query string) — popup.html? current.tab.url
Maybe someone has already done something similar? Thank you!
Answer the question
In order to leave comments, you need to log in
Or maybe I’ll answer myself :) suddenly it will come in handy for someone ...
background.js
// Add a button to Opera's toolbar when the extension loads.
window.addEventListener("load", function() {
// Buttons are members of the UIItem family.
// Firstly we set some properties to apply to the button.
var UIItemProperties = {
disabled: false, // The button is enabled.
title: "vPass", // The tooltip title.
icon: "icon_18.png", // The icon (18x18) to use for the button.
popup: {
href: "https://www.vpass.info/?",
width: "500px",
height: "500px"
},
onclick: function()
{
var extension = window.opera.extension;
var focusedTab = opera.extension.tabs.getFocused();
var url = '';
if(focusedTab)
{
url = focusedTab.url;
button.popup.href='https://www.vpass.info/?'+url;
}
}
};
// Next, we create the button and apply the above properties.
var button = opera.contexts.toolbar.createItem(UIItemProperties);
// Finally, we add the button to the toolbar.
opera.contexts.toolbar.addItem(button);
}, false);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question