function openPage() {
	browser.runtime.openOptionsPage();
}

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
    if (request.action == "xhttp") {
        var method = request.method ? request.method.toUpperCase() : 'GET';
        var options = {
            method: method,
            headers: {}
        };

        if (method == 'POST') {
            options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
            options.body = request.data;
        }

        fetch(request.url, options)
            .then(function(response) {
                return response.text();
            })
            .then(function(text) {
                sendResponse(text);
            })
            .catch(function(error) {
                console.error('Fetch error:', error);
                sendResponse();
            });

        return true; // Keep message channel open for async response
    }
});
