Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

General discussion, compatibility and contributed extensions.

Moderators: satrow, Lootyhoof, FranklinDM

firefoxed
Moonbather
Moonbather
Posts: 71
Joined: Mon, 20 Nov 2017, 02:54

Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby firefoxed » Sat, 09 Feb 2019, 16:57

Like many here, I'm a huge fan of @Legacy Collector's Legacy Mozilla Firefox extensions page on the LegacyCollector website. Don't know about you, but I get tired of always looking through my bookmarks to open that page.

I wrote a simple script to add links to that page in three places: (i) the PaleMoon forum, (ii) the PaleMoon website, (iii) the Add-Ons menu. I figured some of you might also be interested in this very minor mod, so I'm sharing it here.

The text of the link is long to do justice to the name of the repo by Legacy Collector, but customizeable.

Enjoy!

WHAT THIS DOES

1. Adds Link on the Forum:
Image

2. Adds Link in the Menu of the Main PaleMoon page:
Image

3. Adds Link on the Add-Ons page:
Image

DISCLAIMER

This is a basic script that will break when some of the underlying web pages change.

TESTED ENVIRONMENT

- PaleMoon 28
- requires Greasemonkey for Pale Moon (using 3.31.4)

HOW TO INSTALL

0. Make sure you've installed Greasemonkey for Pale Moon (using 3.31.4)
How? On the page linked above, search for greasemonkey-3.31.4-pm_forkBranch.xpi
Click and allow PaleMoon to install.
GreaseMonkey allows user scripts to modify web pages on the fly (among other features).

1. Copy the Script to your Clipboard
Click the "Select All' link, then hit Ctrl + C

Code: Select all

// ==UserScript==
// @name        PaleMoon Add-On Repo
// @namespace   palemoon_addons
// @description Adds links to PaleMoon Forum Pages
// @include       http*://www.palemoon.org/*
// @include       http*://forum.palemoon.org/*
// @include       http*://addons.palemoon.org/extensions/*
// @version     1
// @grant       none
// ==/UserScript==

(function() {

    // config
    var link_text = 'Legacy Firefox Add-Ons Repo'
    // end config

    var this_url = content.document.location

    // two kinds of pages: forum page, and addons page on main PM site
    var addons_page_pattern = new RegExp('addons\.palemoon\.org/extensions')
    var main_page_pattern = new RegExp('www\.palemoon\.org')
    var is_addons_page = addons_page_pattern.test(this_url)
    var is_main_page = main_page_pattern.test(this_url)
    var repo_link = '<a href="http://legacycollector.org/firefox-addons/index.html" target="_blank">' +
                    link_text +
              '</a>'
    var bold_repo_link = '<b>' + repo_link + '</b>'
   
    var standard_replace_pattern = '$1 &nbsp;' + bold_repo_link
              
    if (is_addons_page) {
       parse_pattern = new RegExp('(<h1>Extensions</h1>)')
       replace_pattern = standard_replace_pattern
    }
    else if (is_main_page) {
       parse_pattern = new RegExp('(<li class="li_nc"><a href="https://addons.palemoon.org/extensions/")')
       replace_pattern = '<li class="li_nc">' +
                          repo_link +
               '</li> ' +
               '$1'
    }
    else {
       // this page is a Forum page
       parse_pattern = new RegExp('(<span itemprop="title">Forum index</span></a></span>)')
       replace_pattern = standard_replace_pattern
    }
   
    document.body.innerHTML= document.body.innerHTML.replace(
       parse_pattern,
        replace_pattern 
        )

})()


2. Next to the icon with the monkey face, click the GreaseMonkey pull-down menu, select "New User Script"

3. At the Bottom Left of the next window, select "Use Script from Clipboard"

4. Refresh the pages on which you want to try the script (F5)


5 (Optional). If you want to customize the TEXT of the link:
On a page where the script is active, click the GreaseMonkey pull-down. At the bottom, right-click 'PaleMoon Addo-On Repo'. This opens a text window with the script. Look for the // config section. Modify this line:
var link_text = 'Legacy Firefox Add-Ons Repo'

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4973
Joined: Tue, 09 Oct 2012, 19:37

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby New Tobin Paradigm » Sat, 09 Feb 2019, 17:11

Totally Disgusting.
New Tobin Paradigm

Help I'm steppin' into the Twilight Zone / Place is a madhouse, feels like being cloned
My beacon's been moved under moon and star / Where am I to go, now that I've gone too far

http://binaryoutcast.com/ | http://thereisonlyxul.org/

jars_
Fanatic
Fanatic
Posts: 208
Joined: Tue, 27 Dec 2016, 00:12

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby jars_ » Sat, 09 Feb 2019, 17:25

Awesome! Very cool and usefull script.
Well done :thumbup:

firefoxed
Moonbather
Moonbather
Posts: 71
Joined: Mon, 20 Nov 2017, 02:54

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby firefoxed » Sat, 09 Feb 2019, 18:09

New Tobin Paradigm wrote:Totally Disgusting.


@Tobin It's not my intention to do something reprehensible! My intention was to provide a convenience shortcut to a page that we all already have access to (for instance using Bookmarks), using GreaseMonkey the way it was intended. It sounds like you strongly disapprove. Can you please explain what it is that rubs you the wrong way? I'm really confused.

(Also, since intentions can be hard to decode, I'll just add that there isn't a hint of irony in this message.)

Thanks in advance for clarifying.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4973
Joined: Tue, 09 Oct 2012, 19:37

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby New Tobin Paradigm » Sat, 09 Feb 2019, 20:16

Request denied.
New Tobin Paradigm

Help I'm steppin' into the Twilight Zone / Place is a madhouse, feels like being cloned
My beacon's been moved under moon and star / Where am I to go, now that I've gone too far

http://binaryoutcast.com/ | http://thereisonlyxul.org/

firefoxed
Moonbather
Moonbather
Posts: 71
Joined: Mon, 20 Nov 2017, 02:54

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby firefoxed » Sat, 09 Feb 2019, 20:39

New Tobin Paradigm wrote:Request denied.


Alright, thanks for considering it anyhow.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 23009
Joined: Sun, 28 Aug 2011, 17:27
Location: 58°2'16"N 14°58'31"E
Contact:

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby Moonchild » Sat, 09 Feb 2019, 21:50

I'm not sure what request there is to deny, or what is totally disgusting about someone making the effort to write a script that users can choose to install in their GM or not if they so choose. This is not a request for us to change anything on our sites (which, a propos, we wouldn't) to link to the legacy collector site, or anything of the sort.

If people want to install and run this script to inject extra links in pages then by all means, feel free to do so.
Improving Mozilla code: You know you're on the right track with code changes when you spend the majority of your time deleting code.

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne

firefoxed
Moonbather
Moonbather
Posts: 71
Joined: Mon, 20 Nov 2017, 02:54

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby firefoxed » Sat, 09 Feb 2019, 22:05

@Moonchild

Thank you for your kind and understanding message!...
What I had understood by 'request denied' was that it referred to this specific request:

firefoxed wrote:Can you please explain what it is that rubs you the wrong way? I'm really confused.


...And I try to respect that sometimes people don't want to explain themselves, even though my own preference is for more open communication.

Wishing you all a relaxing Sunday. :coffee:

JSB2000
Apollo supporter
Apollo supporter
Posts: 34
Joined: Tue, 24 Jun 2014, 16:57

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby JSB2000 » Sun, 10 Feb 2019, 01:10

Moonchild wrote:I'm not sure what request there is to deny, or what is totally disgusting about someone making the effort to write a script that users can choose to install in their GM or not if they so choose.


It's Tobin. That's all the answers you need.

Firefoxed: Thank you! Quite useful! Please keep up the good work.
My brief entertainment has a price.

User avatar
New Tobin Paradigm
Knows the dark side
Knows the dark side
Posts: 4973
Joined: Tue, 09 Oct 2012, 19:37

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby New Tobin Paradigm » Sun, 10 Feb 2019, 06:41

JSB2000 wrote:It's Tobin. That's all the answers you need.


Not quite, it is just for the best that I don't elaborate in this instance. It would have been better if I hadn't responded at all but I did.

So let's move on, k?
New Tobin Paradigm

Help I'm steppin' into the Twilight Zone / Place is a madhouse, feels like being cloned
My beacon's been moved under moon and star / Where am I to go, now that I've gone too far

http://binaryoutcast.com/ | http://thereisonlyxul.org/

firefoxed
Moonbather
Moonbather
Posts: 71
Joined: Mon, 20 Nov 2017, 02:54

Re: Script to Add Links to Legacy FF Add-On Repo on PaleMoon Web Pages

Unread postby firefoxed » Thu, 14 Feb 2019, 12:30

Added link to JustOff's Classic Add-On Archive to the text on the extensions page.

To update the script, copy the code below, open a page where the script is running, then click on GreaseMonkey's pull-down menu, right-click on the script, paste, save, refresh the page.do

For purists, sorry about the use of document.body.innerHTML.replace() instead of DOM parsing, it doesn't matter on a static page so I don't see the point and am happy with quick-and-dirty.

Code: Select all

// ==UserScript==
// @name        PaleMoon Add-On Repo
// @namespace   palemoon_addons
// @description Adds links to PaleMoon Forum Pages
// @include       http*://www.palemoon.org/*
// @include       http*://forum.palemoon.org/*
// @include       http*://addons.palemoon.org/extensions/*
// @version     1
// @grant       none
// ==/UserScript==

(function() {

    // config
    var link_text = 'Legacy_Add-Ons_Repo'
    // end config

    var this_url = content.document.location

    // two kinds of pages: forum page, and addons page on main PM site
    var addons_page_pattern = new RegExp('addons\.palemoon\.org/extensions')
    var main_page_pattern = new RegExp('www\.palemoon\.org')
    var is_addons_page = addons_page_pattern.test(this_url)
    var is_main_page = main_page_pattern.test(this_url)
    var repo_link = '<a href="http://legacycollector.org/firefox-addons/index.html" target="_blank">' +
                    link_text +
              '</a>'
    var bold_repo_link = '<b>' + repo_link + '</b>'
   
    var standard_replace_pattern = '$1 &nbsp;' + bold_repo_link
              
    if (is_addons_page) {
       parse_pattern = new RegExp('(<h1>Extensions</h1>)')
       replace_pattern = '$1<b>=== Also See ===<br>1.&nbsp;</b>' +
                          bold_repo_link +
                          '<br><b>2.&nbsp;<a href="https://github.com/JustOff/ca-archive" target="_blank">Add-On Archive</a> (great extension that lets you search and install old Add-Ons)</b>' +
                          '<br><b>===</b>'
    }
    else if (is_main_page) {
       parse_pattern = new RegExp('(<li class="li_nc"><a href="https://addons.palemoon.org/extensions/")')
       replace_pattern = '<li class="li_nc">' +
                          repo_link +
               '</li> ' +
               '$1'
    }
    else {
       // this page is a Forum page
       parse_pattern = new RegExp('(<span itemprop="title">Forum index</span></a></span>)')
       replace_pattern = standard_replace_pattern
    }
   
    document.body.innerHTML= document.body.innerHTML.replace(
       parse_pattern,
        replace_pattern 
        )

})()


Return to “Browser extensions”

Who is online

Users browsing this forum: asimperson, BLEXBot [Crawler] and 1 guest