Bookmarket to show a page's links & URLs with links on the URLs

I have a great bookmarklet created by one of the experts here, mplungjan, that will list all the links on a page & the URLs for each link.  This is the code:
javascript:(function()%20{var%20links%20=%20document.links;var%20html%20=%20'<table>';for%20(var%20i=0,n=links.length;i<n;i++)%20{%20if%20(links[i].href!='')%20html%20+=%20'<tr><td>'+links[i].textContent+'</td><td>'+links[i].href+'</td></tr>';}%20html%20+='</table>';%20var%20w=window.open('','_blank');if%20(w)%20{w.document.write(html);w.document.close()};})()

Open in new window


For 350 points, can you modify this so that:
1) The URL text on the right in the output is linked to the actual pages so that the pages open up in a new tab  
2) Let me know how to modify it if I wanted the URLs to open in a new browser instead of new tab.

For 500 points, add these features from the "search links" bookmarket at https://www.squarefree.com/bookmarklets/pagelinks.html#search_links
3) Limit the output by a string if desired
4) Put the link for the source page on the top of the output
5) Put numbers on each line in the output

Thanks!
leslieinvaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nap0leonCommented:
URLs are links:
javascript:(function()%20{var%20links%20=%20document.links;var%20html%20=%20'<table>';for%20(var%20i=0,n=links.length;i<n;i++)%20{%20if%20(links[i].href!='')%20html%20+=%20'<tr><td>'+links[i].textContent+'</td><td><a href="'+links[i].href+'">'+links[i].href+'</a></td></tr>';}%20html%20+='</table>';%20var%20w=window.open('','_blank');if%20(w)%20{w.document.write(html);w.document.close()};})()

Open in new window


Open each link in a new window
javascript:(function()%20{var%20links%20=%20document.links;var%20html%20=%20'<table>';for%20(var%20i=0,n=links.length;i<n;i++)%20{%20if%20(links[i].href!='')%20html%20+=%20'<tr><td>'+links[i].textContent+'</td><td><a href="'+links[i].href+'"%20target="_blank">'+links[i].href+'</a></td></tr>';}%20html%20+='</table>';%20var%20w=window.open('','_blank');if%20(w)%20{w.document.write(html);w.document.close()};})()

Open in new window

(to make them all open in the same new window, change "_blank" to whatever you want the name of the new window to be)

Adding the Originating URL to the top as an H1 tag:
javascript:(function()%20{var%20links%20=%20document.links;var%20html%20='<h1>'+document.location+'</h1><table>';for%20(var%20i=0,n=links.length;i<n;i++)%20{%20if%20(links[i].href!='')%20html%20+=%20'<tr><td>'+links[i].textContent+'</td><td><a href="'+links[i].href+'"%20target="_blank">'+links[i].href+'</a></td></tr>';}%20html%20+='</table>';%20var%20w=window.open('','_blank');if%20(w)%20{w.document.write(html);w.document.close()};})()

Open in new window


No clue on the line numbers.
No clue what you mean by "limit the string if I want"  You mean limit the displayed URL to only the first N characters?  If so, here is an example that limits it to the first 20 characters.  
javascript:(function()%20{var%20links%20=%20document.links;var%20html%20='<h1>'+document.location+'</h1><table>';for%20(var%20i=0,n=links.length;i<n;i++)%20{%20if%20(links[i].href!='')%20html%20+=%20'<tr><td>'+links[i].textContent+'</td><td><a%20href="'+links[i].href+'"%20target="_blank">'+links[i].href.slice(0,20)+'</a></td></tr>';}%20html%20+='</table>';%20var%20w=window.open('','_blank');if%20(w)%20{w.document.write(html);w.document.close()};})()

Open in new window


To change the number of characters, edit this part
links[i].href.slice(0,20)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leslieinvaAuthor Commented:
OK,  we're up to 400 points.

To see what I mean by "Limit the output by a string if desired" try out the bookmarklet called "search links" at https://www.squarefree.com/bookmarklets/pagelinks.html#search_links.  
It prompts for a string (word or phrase), and then lists links on the page that contain that string in a new window. The string may appear in the link's target url or in its anchor text. If you leave the prompt blank, all links on the page will be listed.  It also add line numbers.
0
leslieinvaAuthor Commented:
Still looking for the part that would allow filtering the output by a dynamically entered string.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.