Linking suggestion

Announcements, comments, ideas, feedback, and "How do I... ?" questions
Post Reply
Ward
Posts: 1
Joined: Tue Jul 08, 2008 5:41 pm

Linking suggestion

Post by Ward »

On this page:
http://projecteuler.net/index.php?section=activity
perhaps add a link to the users profile?


On these pages:
http://projecteuler.net/index.php?secti ... w=unsolved
http://projecteuler.net/index.php?secti ... how=solved
(I added the show=unsolved as a GET because well... it's hard to include a POST in a link)
making the headers link to the problems like it already is on this page: (wondering why the different approach)
http://projecteuler.net/index.php?secti ... l&show=all

(more precisely, instead of <h2>Problem N</h2>, add the <a> tag there is when viewing all problems)




If for some reason you (owners of projecteuler) don't want to do this, I have this for anyone who shares my "grief":
(GreaseMonkey scripts)

Code: Select all

// ==UserScript==

// @name           Create Links

// @namespace      ProjectEuler

// @description    Turns the online user list in a list with links to profile

// @include        http://projecteuler.net/index.php?section=activity

// ==/UserScript==

divs = document.getElementsByTagName("div");

for (var i = 0; i < divs.length; i++)
{
    if (divs[i].className == "rbcontent" && divs[i].innerHTML.match("User Activity"))
    {
        divs[i].innerHTML = divs[i].innerHTML.replace(/(<span.*?>)(.+?)<\/span>/g,
                               "$1"
                               + "<a href=\"http://projecteuler.net/index.php?section=profile&profile=" + "$2" + "\" target=\"_blank\">"
                               + "$2"
                               + "</a></span>");
    }
}

Code: Select all

// ==UserScript==

// @name           CreateLinks2

// @namespace      ProjectEuler

// @description    On the unsolved problems page, change the headers into links to the problem

// @include        http://projecteuler.net/index.php?section=view_all&show=unsolved

// @include        http://projecteuler.net/index.php?section=view_all

// @include        http://projecteuler.net/index.php?section=view_all&show=solved

// ==/UserScript==



// Get all the <h2> headers
var h2 = document.getElementsByTagName("h2");

// Loop&replace
for (var i = 0; i < h2.length; i++)
{
    h2[i].innerHTML = h2[i].innerHTML.replace(/^Problem (.+)$/, '<a href="http://projecteuler.net/index.php?section=problems&id='
                                                              + "$1" + '" target="_blank">Problem ' + "$1" + '</a>');
}


Cheers,
Ward
User avatar
euler
Administrator
Posts: 5095
Joined: Sun Mar 05, 2006 4:49 pm
Location: Cheshire, England
Contact:

Re: Linking suggestion

Post by euler »

I don't know why I had the "view_all" module rendering both differently?

Anyway, all good ideas/observations... so job done! 8-)
Image
impudens simia et macrologus profundus fabulae
Post Reply