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

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

firefoxed

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

Unread post by firefoxed » 2019-02-09, 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'

New Tobin Paradigm

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

Unread post by New Tobin Paradigm » 2019-02-09, 17:11

Totally Disgusting.

User avatar
jars_
Lunatic
Lunatic
Posts: 397
Joined: 2016-12-27, 00:12

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

Unread post by jars_ » 2019-02-09, 17:25

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

firefoxed

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

Unread post by firefoxed » 2019-02-09, 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.

New Tobin Paradigm

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

Unread post by New Tobin Paradigm » 2019-02-09, 20:16

Request denied.

firefoxed

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

Unread post by firefoxed » 2019-02-09, 20:39

New Tobin Paradigm wrote:Request denied.
Alright, thanks for considering it anyhow.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35481
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

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

Unread post by Moonchild » 2019-02-09, 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.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

firefoxed

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

Unread post by firefoxed » 2019-02-09, 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

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

Unread post by JSB2000 » 2019-02-10, 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.

New Tobin Paradigm

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

Unread post by New Tobin Paradigm » 2019-02-10, 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?

firefoxed

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

Unread post by firefoxed » 2019-02-14, 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  
        )

})()

User avatar
bawldiggle
Lunatic
Lunatic
Posts: 446
Joined: 2013-02-22, 21:16
Location: East Coast Australia

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

Unread post by bawldiggle » 2019-05-06, 07:03

Thanks firefoxed for your nifty script ... :thumbup:
Win-7 PRO 64-bit
Palemoon; auto updates current version (32-bit)

Locked