Как в Opera extension popup открыть страницу с текущим URL в качестве query?

Всем привет!


Хочу написать Opera extension для вот этого — vPass. Мне нужно, чтобы по нажатию на кнопку расширения открывался попап с текущим URL в качестве параметра (query string) — popup.html?current.tab.url


Может кто нибудь уже делал нечто подобное? Спасибо!
  • Вопрос задан
  • 3056 просмотров
Пригласить эксперта
Ответы на вопрос 1
vladstudio
@vladstudio Автор вопроса
А можно я сам себе отвечу :) вдруг кому пригодится…

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);

Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы