I know I must be missing something obvious but I've spent the past 2 hours trying to work this one out. What I'm trying to do is get some information from the active tab, specifically a variable from the URL and the content of a textarea.
I can't seem to retrieve either of these from within my Chrome extension
Here is my ticket.js
function getQueryVariable(variable)
{
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){return pair[1];}
}
return(false);
}
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
console.log(tabs[0].url);
var ticketID = getQueryVariable("id");
console.log(ticketID);
var inputTicket= document.getElementById('bottom_message').value;
console.log(inputTicket);
});
Now when I run it nothing happens. My popup.js is blank and I currently don't need it to do anything popup related, however, do I need to reference ticket.js within popup.js?
Here is my manifest
{
"manifest_version": 2,
"name": "Autosave",
"description": "Extension Ticket system to autosave text in a ticket",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
},
"permissions": [
"activeTab",
"tabs"]
"content_scripts": [
"matches": ["https://portal.ticketsystem.co.uk/*"],
"js": ["ticket.js"]
}