Desperatly need for NewTab randomizer. Topic is solved

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

Moderators: FranklinDM, Lootyhoof

ambivalence

Desperatly need for NewTab randomizer.

Unread post by ambivalence » 2017-09-10, 21:49

There's a linklist I'd like to monitor from time to time, and it would be great to see them when new tab is opened. Any suggestions, please?

tooshorttoolong
Fanatic
Fanatic
Posts: 137
Joined: 2017-09-11, 14:28

Re: Desperatly need for NewTab randomizer.

Unread post by tooshorttoolong » 2017-09-11, 15:02

I’m not sure what you mean exactly by "linklist", but you can change the new tab page to whatever you want.

Install the Pale Moon Commander addon, which adds a Tools->Advanced menu.
In the Pale Moon Commander window, select User Interface -> General.
At the bottom there is a New tab URL field.
(You can also change that value in about:config without installing PMC.)

You could try to point that URL to a local file containing your link list.

ambivalence

Re: Desperatly need for NewTab randomizer.

Unread post by ambivalence » 2017-09-14, 00:13

Thanks, but I meant list of links actually, so that's why I need some kind of randomizer or iterator for them.

tooshorttoolong
Fanatic
Fanatic
Posts: 137
Joined: 2017-09-11, 14:28

Re: Desperatly need for NewTab randomizer.

Unread post by tooshorttoolong » 2017-09-14, 12:51

I was thinking something could be made in javascript, but I’m not an expert and it seems to be harder than I thought (access to local filesystem files is not easy, if at all possible).

ambivalence

Re: Desperatly need for NewTab randomizer.

Unread post by ambivalence » 2017-09-20, 18:20

It could be a list stored in the extension's settings (in the about:config eventually).

Falna
Astronaut
Astronaut
Posts: 512
Joined: 2015-08-23, 17:56
Location: UK / France

Re: Desperatly need for NewTab randomizer.

Unread post by Falna » 2017-09-20, 19:57

Still not entirely sure what you're aiming to do, however the extension Update Scanner https://addons.mozilla.org/en-GB/firefox/addon/update-scanner/ might be a more sophisticated way of doing what you're trying to do? It's listed as incompatible with PM, but will install no problem with compatibility checking disabled (and no doubt with the Moon Tester tool).

Forked extensions :
● Add-ons Inspector ● Auto Text Link ● Copy As Plain Text ● Copy Hyperlink Text ● FireFTP button replacement ● gSearch Bar ● Navigation Bar Enhancer ● New Tab Links ● Number Tabs ● Print Preview Button and Keyboard Shortcut 2 ● Scrollbar Search Marker ● Simple Marker ● Tabs To Portfolio ● Update Alert ● Web Developer's Toolbox ● Zap Anything

Hint: If you expect a reply to your PM, allow replies...

ambivalence

Re: Desperatly need for NewTab randomizer.

Unread post by ambivalence » 2017-09-21, 13:40

What I mean:

a) Open new tab → see page 1
b) Open new tab → see page 2
c) Open new tab → see page 3
d) Open new tab → see page 1…

And the ability to customize these pages, that's it.

What I always see here and there are addons that just allows to change newtab url, meaning there's only one link user can set.

tooshorttoolong
Fanatic
Fanatic
Posts: 137
Joined: 2017-09-11, 14:28

Re: Desperatly need for NewTab randomizer.

Unread post by tooshorttoolong » 2017-09-21, 14:25

Ok I’ve got something that seems to work, if you don’t mind editing the list of URLs in the code manually.
Create a new file named for example "NewTab.html" and save it wherever you want, and paste this code inside it:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<script>
// setCookie and getCookie from https://www.w3schools.com/js/js_cookies.asp
function setCookie(cname, cvalue, exdays) {
    var d = new Date();
    d.setTime(d.getTime() + (exdays*24*60*60*1000));
    var expires = "expires="+ d.toUTCString();
    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
    var name = cname + "=";
    var decodedCookie = decodeURIComponent(document.cookie);
    var ca = decodedCookie.split(';');
    for(var i = 0; i <ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return -1;
}
function randomPage() {
	var urlList = [
		"https://www.gamingonlinux.com/",
		"https://www.anandtech.com/",
		"https://www.duniter.org/"
	]
	n = getCookie("lastpage")
	n++
	if (n >= urlList.length) {
		n = 0
	}
	setCookie("lastpage", n, 30)
	window.open(urlList[n], '_self', false)
}
</script>
</head>
<body onload="randomPage()">
</body>
</html>
Save it, then change the new tab url of PM to the path to this file:

Code: Select all

file:///path/to/NewTab.html
Works for me!

Locked