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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:01:48+00:00 2026-05-16T18:01:48+00:00

My Greasemonkey scripts all work in Firefox 3.6, but in Chrome 6 nothing special

  • 0

My Greasemonkey scripts all work in Firefox 3.6, but in Chrome 6 nothing special happens when I load a page that is supposed to trigger them. Here‘s an example script (pasted below) that highlights top comments on Hacker News. Can anyone identify what I’m doing wrong? When I click on the user.js file and install it in Chrome, the installation succeeds.

// ==UserScript==
// @name           Hacker News highlight
// @namespace      http://news.ycombinator.com
// @description    highlights popular comments
// @include        http://news.ycombinator.com/item*

// ==/UserScript==

var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);

// Check if jQuery's loaded
function GM_wait() {
    if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}

GM_wait();

function letsJQuery() { 

    var maxScore = 0;
    var secBest = 0;
    var min = 0;

    var numComments = 0;
    $(".comhead > span").each(function() {
        numComments = numComments + 1;
        var score = parseInt($(this).text().split(' ')[0]);
        if(score > maxScore) {
            maxScore = score;
        }
        else if(score > secBest) {
            secBest = score;
        }
    });

    min = maxScore - secBest;

    $(".comhead > span").each(function() {
        var score = parseInt($(this).text().split(' ')[0]);

        if(min!=0 && score >= min + 1) {
            $(this).css({'background-color':'#B2D7FB', 'padding':'4px 4px 4px 4px','-moz-border-radius':'3px', '-webkit-border-radius':'3x'});      
        }
    });
}
  • 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-05-16T18:01:49+00:00Added an answer on May 16, 2026 at 6:01 pm

    I have found it easiest to access page resources by injecting my code into the DOM:

    // ==UserScript==
    // @name           Hacker News highlight
    // @namespace      http://news.ycombinator.com
    // @description    highlights popular comments
    // @include        http://news.ycombinator.com/item*
    // @run-at         document-end
    // ==/UserScript==
    
    function letsJQuery() {
       // your stuff
    }
    
    var jQuery = document.createElement("script"),
        inject = document.createElement("script");
    
    jQuery.setAttribute("type", "text/javascript");
    jQuery.setAttribute("src", "http://code.jquery.com/jquery-latest.js");
    
    inject.setAttribute("type", "text/javascript");
    inject.appendChild(document.createTextNode("(" + letsJQuery + ")()"));
    
    document.body.appendChild(jQuery);
    document.body.appendChild(inject);
    

    The @run-at ensures that the script loads immediately after DOMDocumentReady, just as in Greasemonkey, and I changed your jQuery URL to point to their CDN.

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

Sidebar

Related Questions

I've got quite a few GreaseMonkey scripts that I wrote at my work which
I developed a greasemonkey script that refreshes a page and checks for certain updates.
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
Can I save page pictures from GreaseMonkey script directly to my hard drive? Is
I have a very simple greasemonkey script that I want to call an already
I was sitting here wondering if it's possible to write a greasemonkey script that
I have a greasemonkey user script with this single line of code... window.close(); but
i am new to greasemonkey. I'd like to create scripts to change my favourite
I have captured list of data from the page using Greasemonkey. GM Script var
How to change web-page without link, using greasemonkey? Is it even possible? For e.g.

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.