Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

155
Views
Storing items into a list from the values fetched by background script

I am new to extensions. my extension's purpose is to save the URLs of all tabs ever opened on the browser. This is my background script so far:

var URLs = [];
chrome.history.onVisited.addListener(storeURL);
chrome.storage.onChanged.addListener(function (changes, namespace) {
    for (let [URL, { oldValue, newValue }] of Object.entries(changes)) {
        URLs[URLs.length] = newValue;
    }
});

function storeURL(HistoryItem) {
    console.log("entered in storeURL function", HistoryItem)
    chrome.storage.sync.set({ URL: HistoryItem?.url }, function () {
        console.log('URL is set to ' + HistoryItem?.url);
    });
}

The problem is that i am able to access the current url in developer tools but its not being stored in URLs. Note: I want the extension to be autonomous and not popup. my manifest.json:

{ 
    "name": "URL tracker",
    "version": "0.0.1",
    "manifest_version": 3,
    "description": "Stores the browser URLs",
    "action": {
        "default_popup": "url.html",
        "default_icon": "logo-small.png"
    },
    "background": {
        "service_worker": "background.js"
    },
    "content_scripts": [
        {
            "matches": ["<all_urls>"],
            "css": [],
            "js": ["content.js"]
        }
    ],
    "icons": {
        "128": "logo-small.png",
        "512": "logo-small-2.png"
    },
    "permissions": [
        "history",
        "tabs",
        "activeTab",
        "storage"
    ]
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!