Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7906307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:52:58+00:00 2026-06-03T10:52:58+00:00

I am having some issues with an extension that i am trying to make.

  • 0

I am having some issues with an extension that i am trying to make. The extension’s job is to check URLs before making the request and block the ones that are available in the list provided. The manifest.json file loads flagged.js which declares and initializes the array. Then, it loads the file that has the function to check URLs:

// To detected and filter globally flagged websites
chrome.webRequest.onBeforeRequest.addListener(
    // What to do if detected a website
    function(info) {

        return {redirectUrl: 'chrome-extension://' + chrome.i18n.getMessage('@@extension_id') + 
            '/blocked.html?flag_type=globally&url=' + escape(info.url)};
    },

    // Website to watchout for
    {
        urls: flagged,
        types: []
    },

    // Action to be performed?
    ["blocking"]);

My issue starts with the part urls: flagged, it seems the list must be hardwired in order to be accepted. What i mean to say, is that i must specify the list items as such:

var flagged = [
"*://*.domain_1.com/*",
"*://*.domain_2.com/*",
"*://*.domain_3.com/*",
"*://*.domain_4.com/*",
];

If i attempt to go to any of the above specified domains, the extension will redirect them to the block.html page no problems. However, i want that list to be automatically or periodically updated, so i introduced this part:

// Get list from the text file we have stored
function getFlagged(url) {
    var list = [];
    var file = new XMLHttpRequest();
    file.open("GET", url, true);
    file.onreadystatechange = function() {
        if (file.readyState === 4) {
            if (file.status === 200) {
                allText = file.responseText; 
                list = file.responseText.split('|');
                    for( var i=0; i<list.length; i++ )
                        flagged.push(list[i]);
            }
        }
    }
    file.send(null);
}

I have tried to change and add things that may not make sense or could be done differently, i was just desperate. The list will be populated with the new items, say *domain_5* and *domain_6* for example. This operation will occur first thing when the extension is being loaded, or so i think. However, when i try to access *domain_5* and *domain_6*, the extension does NOT block them despite the fact that they are in the list flagged.

Any help with this issue would be very appreciated!
Thank you

EDIT: I am not an expert on JS or Chrome.APIs, this is my first attempt at chrome extensions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T10:53:00+00:00Added an answer on June 3, 2026 at 10:53 am

    Yeah, Your Listener is registering before the XMLHttpRequest is finished.

    Call the listener in your onreadystatechange function and you’ll get it to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues with some jQuery code, and I'm hoping and thinking that
I'm having some issues where when if I run this C extension outside of
I am having some issues with using the OrderBy extension method on a LINQ
Im having some issues trying to adjust the Width of some of the items
Having some issues trying to model bind to my view model. The basic viewmodel
Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
I'm having some issues with an asp.net implementation of this JQuery facebook style autocomplete
I'm having some issues with my code. This is probably due to some design
I am having some issues with logging. After reviewing JBoss Seam source code, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.