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 8887857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:54:42+00:00 2026-06-14T21:54:42+00:00

This problem seems to have been sort of resolved, as long as the URL

  • 0

This problem seems to have been sort of resolved, as long as the URL of the page you’re injecting your javascript into starts with www. What do you do if it doesn’t? Here’s the relevant part of my manifest:

"content_scripts": [
  {
  "run_at": "document_start",
  "matches": ["https://groups.google.com/forum/?fromgroups=#!newtopic/opencomments-site-discussions"],
  "js": ["postMsg.js"]
  }
],

The problem, according to another stackoverflow post, is because the URL of the page doesn’t begin with ‘www’. Does that mean that you can’t inject javascript into secure pages whose URL doesn’t begin with ‘www’, or is there another way? This had never been a problem in the past, because my extension had run with Version 1 manifests.

Forgot to add the content script:

var subject = document.getElementById("p-s-0");

subject.setAttribute("value", "foo");   

The element with ID “p-s-0” is the Subject field in the Google Groups Post page, so the field should display “foo”.

  • 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-14T21:54:43+00:00Added an answer on June 14, 2026 at 9:54 pm

    A few issues:

    1. That is a not valid match pattern because they only specify up to the URL path (the part before the ?).

      Change the matches to:

      "matches": ["https://groups.google.com/forum/*"],
      

    2. The overall URL (https://groups.google.com/forum/?fromgroups=#!newtopic/opencomments-site-discussions) is not practical because Google changes the URL parameters willy nilly. For example, fromgroups is not often present, and may not have the = if it is. Additional parameters, like hl=en come and go. (This is the reason why my earlier answer worked for me, but not for you.)

      So, using include_globs in the manifest would be a messy, error-prone exercise.
      The solution is to checklocation.hash within the content script.

    3. The script is set to "run_at": "document_start", so the content script is running before there is any node with id p-s-0.

      Change the manifest to "run_at": "document_end".

    4. The new Google groups is heavily AJAX driven. So, The “New Topic” page is usually “loaded” without actually loading a whole new page. This means the content script will not rerun. It needs to monitor for “new” AJAX-loaded pages.

      Check for “new” pages by monitoring the hashchange event.

    5. Additionally, the p-s-0 element is added by AJAX, and is not immediately available on a “new” page. Check for this element within a setInterval.


    Putting it all together,
    The manifest.json becomes:

    {
        "manifest_version": 2,
        "content_scripts": [ {
            "run_at":           "document_end",
            "js":               [ "postMsg.js" ],
            "matches":          [ "https://groups.google.com/forum/*" ]
        } ],
        "description":  "Fills in subject when posting a new topic in select google groups",
        "name":         "Google groups, Topic-subject filler",
        "version":      "1"
    }
    

    The content script(postMsg.js) becomes:

    fireOnNewTopic ();  // Initial run on cold start or full reload.
    
    window.addEventListener ("hashchange", fireOnNewTopic,  false);
    
    function fireOnNewTopic () {
        /*-- For the pages we want, location.hash will contain values
            like: "#!newtopic/{group title}"
        */
        if (location.hash) {
            var locHashParts    = location.hash.split ('/');
            if (locHashParts.length > 1  &&  locHashParts[0] == '#!newtopic') {
                var subjectStr  = '';
                switch (locHashParts[1]) {
                    case 'opencomments-site-discussions':
                        subjectStr  = 'Site discussion truth';
                        break;
                    case 'greasemonkey-users':
                        subjectStr  = 'GM wisdom';
                        break;
                    default:
                        break;
                }
    
                if (subjectStr) {
                    runPayloadCode (subjectStr);
                }
            }
        }
    }
    
    function runPayloadCode (subjectStr) {
        var targetID        = 'p-s-0'
        var failsafeCount   = 0;
        var subjectInpTimer = setInterval ( function() {
                var subject = document.getElementById (targetID);
                if (subject) {
                    clearInterval (subjectInpTimer);
                    subject.setAttribute ("value", subjectStr);
                }
                else {
                    failsafeCount++;
                    //console.log ("failsafeCount: ", failsafeCount);
                    if (failsafeCount > 300) {
                        clearInterval (subjectInpTimer);
                        alert ('Node id ' + targetID + ' not found!');
                    }
                }
            },
            200
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue that seems like very flaky behavour, is this a problem
This seems like a simple problem: I have a WF4 activity that guides the
hello all this seems to be my problem I have a table in mysql
I have this code and can't figure out what seems to be the problem:
This problem seems very simple to me, but I've been unable to fix it,
i have been over so many posts online trying to sort this.... i am
This seems like a pretty common problem, but I haven't found any sort of
I seem to have the exact opposite problem than this question on stopping dock
hey guys having this really simple problem but cant seem to figure out have
I am struggling for days to solve this problem and it seems i cant

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.