XMLHttpRequest called from extension stopped working
-
A Former User last edited by
Hi everybody! I have a tiny extension that reports Opera's active tab to a Mac time tracker running locally.
It uses the same code for Chromium, Firefox, and Opera but recently it stopped working in Opera. It seems that
XMLHttpRequest
can't be sent anymore.How can I work around that? Is there any new permission I'm missing? Thanks!
The extension and the manifest code:
function checkUrl() { chrome.tabs.query({ active: true, lastFocusedWindow: true }, function(tabs) { if (tabs.length > 0) { var tabUrl = tabs[0].url; var tabName = tabs[0].title; var isIncognito = tabs[0].incognito; console.log(tabUrl + " " + tabName + " " + isIncognito); var requestUrl = "http://localhost:27272/?url=" + encodeURIComponent(tabUrl) + "&title=" + encodeURIComponent(tabName) + "&private=" + isIncognito; var xmlHttp = new XMLHttpRequest(); xmlHttp.open("POST", requestUrl, true); xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlHttp.send(null); } }); } chrome.tabs.onActivated.addListener(function(info) { checkUrl(); }); chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { checkUrl(); }); chrome.windows.onFocusChanged.addListener(function(windowId) { checkUrl(); });
{ "description": "Extension to communicate with Qbserve time tracker", "manifest_version": 2, "name": "Qbserve", "version": "1.5", "homepage_url": "https://qotoqot.com/qbserve/", "icons": { "32": "icons/qbserve-32.png", "48": "icons/qbserve-48.png", "64": "icons/qbserve-64.png", "96": "icons/qbserve-96.png" }, "permissions": [ "tabs", "http://localhost:27272/*" ], "background": { "scripts": ["qbserve.js"] } }