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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:51:24+00:00 2026-06-04T00:51:24+00:00

I’m trying to create a GreaseMonkey script that automatically extends the list of alerts

  • 0

I’m trying to create a GreaseMonkey script that automatically extends the list of alerts in GitHub’s newsfeed but that doesn’t work.

Here is my code (inspired from this post):

var moreLink = $("a:contains('More')");
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
moreLink[0].dispatchEvent(evt);

But instead of expending the list of alerts like it does when you manually click on it, it just opens the page the link points too (https://github.com/organizations/my_organization?page=2)

How can I do this?

Edit:
Here is the HTML source code of the link, it looks like there is no javascript or onClick event associated to it:

<a href="/organizations/my_organization?page=2">More</a>

Edit 2:
Here is my full greasemonkey script:

// ==UserScript==
// @name        test
// @namespace   test
// @description test
// @include     https://github.com
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js
// @version     1
// ==/UserScript==

var moreLink = $("#dashboard div.news div.pagination a:contains('More')");
var evt = document.createEvent("MouseEvents");
evt.initEvent("click", true, true);
moreLink[0].dispatchEvent(evt);
//alert($(".alert").length);
  • 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-04T00:51:27+00:00Added an answer on June 4, 2026 at 12:51 am

    Your code works perfectly for me — on the main page, when logged in. Though I would recommend that you use a more specific selector, to avoid false positives.

    EG, use:

    var moreLink = $("#dashboard div.news div.pagination a:contains('More')");
    

    • What version of Firefox and Greasemonkey are you using?
    • Is NoScript, Adblock, or similar running?
    • You say that it looks like there is no javascript or onClick event associated with the link… How did you check? Firebug shows several event-listeners on that node.
    • What errors appear in Firefox’s error console (CtlShiftJ), besides the zillions of CSS warnings that GitHub generates?
    • Is your script doing anything else to the page? Especially adding or deleting content or using innerHTML? If so, post or link to the full script.

    Update for new information:

    1. On further testing, from more environments, it now appears as if GitHub’s pagination is not always initialized by the time the Greasemonkey script fires. To get around that, use the waitForKeyElements() utility and check for pagination-engine readiness before attempting to click the link. See below.

    2. Greasemonkey 0.9.19 was buggy as all get-out — hence it was only active for a few days.
      Go to the Greasemonkey Version History page and install either version 0.9.20 or version 0.9.18.

    3. The @include directive may not be firing when you want it. It needs to be at least:

      // @include https://github.com/
      

      But

      // @include https://github.com/*
      

      might be better, and the selector is specific enough that a broader include should cause no harm.

    4. Step up to jQuery version 1.7.2 — we’ve used it extensively with no problems. (1.5.1 is probably not the problem, but best to eliminate that variable.)

    Putting all that together, the following script works for me, from a variety of (Windows) environments. I left most of the debugging code in, just in case…

    // ==UserScript==
    // @name        _GitHub "news" item auto-paging
    // @namespace   _pc
    // @include     https://github.com/
    // @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @require     https://gist.github.com/raw/2625891/waitForKeyElements.js
    // ==/UserScript==
    
    if (typeof unsafeWindow.console.clear != 'undefined') {
        unsafeWindow.console.clear ();
    }
    unsafeWindow.console.log ("Start...");  //-- Does not require Firebug.
    
    waitForKeyElements (
        "#dashboard div.news div.pagination a:contains('More')",
        clickAjaxMoreLink,
        true    //-- Stop on first successful click.
    );
    
    function clickAjaxMoreLink (jNode) {
        this.numRuns    = this.numRuns || 1;
    
        unsafeWindow.console.log (
            "moreLink:", jNode,
            " | Parent classes:", jNode.parent ().attr ("class"),
            " | Run:", this.numRuns
        );
        this.numRuns++;
        /*--- COMMENT THIS NEXT CHECK OUT, if waitForKeyElements is set to
            continually click via clickAjaxMoreLink. (The last param is false.)
        */
        if (this.numRuns > 25) {
            unsafeWindow.console.log ("*** Excessive runcount, abort! ***");
            return false;
        }
    
        if (jNode.parent ().hasClass ("loading") ) {
            return true;    //-- Cancel the "found" status.
        }
        var unsfJQ_Body = unsafeWindow.$(document.body);
        if (    ! unsfJQ_Body
            ||  ! unsfJQ_Body.length
            ||  document.readyState != "complete"   //-- Order is important here
            ||  (typeof unsfJQ_Body.pageUpdate) != "function"
        ) {
            return true;
        }
    
        unsafeWindow.console.log ("Num news items, start:", $(".alert").length);
    
        setTimeout ( function () {
            unsafeWindow.console.log (
                "Num news items, after AJAX delay:", $(".alert").length
            );
        }, 2333);
    
        var evt = document.createEvent ("MouseEvents");
        evt.initEvent ("click", true, true);
        jNode[0].dispatchEvent (evt);
    
        return false;
    }
    
    unsafeWindow.console.log ("Setup complete...");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.