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'm interested in writing some Chrome compatible Greasemonkey scripts, but I'm finding that there
I've got quite a few GreaseMonkey scripts that I wrote at my work which
What's the best way to debug custom User Scripts (aka Greasemonkey) in Chrome? Is
Background : I'm currently writing a greasemonkey script that embeds/modifies a specific page's html.
I'm used to making Greasemonkey scripts for Firefox, where I can edit the script
I have a Greasemonkey script that works just fine in Firefox and Opera. I
I created the following Greasemonkey script to be executed on Firefox for all websites.
I would like to write a greasemonkey script that given an xpath returns all
I'm writing a UserScript (=Greasemonkey) which I am developing in FireFox but works in
I'm trying to do a userscript for Chrome and Greasemonkey in Firefox. I'm using

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.