Possibly, unheard-of Firefox addon....

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Hi, I'm looking for a possibly unheard-of add-on for Firefox.....

something that will disable all external links from a given site. I'm setting up a PC for someone and once they navigate to a site (e.g. News.com) using a bookmark, I want them to be "glued" to that site and only be able to browse within this site (this domain and subdomains).

Kind of a limited, no-external-links-allowed browsing mode. Blacklisting every single external URL wouldn't work - there are too many... To be clear, I do want images and stuff to be downloaded and displayed from external sites, I just don't want the external links to work. i know,

Radical ideas? Thanks!
 

lxskllr

No Lifer
Nov 30, 2004
59,143
9,584
126
That sounds like it wouldn't be too difficult from a programming POV, but it would cause issues using the web. What if the person searched with Google? They'd use Google fine, but couldn't click the links it provided.

I'm curious about your end goal. Why do you want to block links?
 

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Reasons behind this:

I am setting up a PC for someone who is only going to view the sites I put in the Bookmarks. They aren't interested in "surfing the Web", only in reading these specific sites. As such, anything that allows them to go "out" and fully surf the web is undesired.

This is similar to a restricted "kiosk" mode and I'd love to accomplish this without writing/editing scripts.

Bottom line... If they open a site using a bookmark, all external links from this site should become disabled or blocked.

Let's do this! :)
 

NetGuySC

Golden Member
Nov 19, 1999
1,643
4
81
perhaps set up a whitelist of approved sites on your router or browser and then block any .com not that is not on your whitelist. Not sure if this is even doable. Perhaps a parental control program.

If you are willing to use internet explorer, here's a page explaining how to do exactly this..
http://www.boutell.com/newfaq/browser/restrictie.html
 
Last edited:

lxskllr

No Lifer
Nov 30, 2004
59,143
9,584
126
perhaps set up a whitelist of approved sites on your router or browser and then block any .com not that is not on your whitelist. Not sure if this is even doable.

The problem is he wants stuff to come in from the outside, but not allow the person to browse to the outside. IOW, embedded YouTube he wants, but he doesn't want the person to be able to click to YouTube. I'm playing around with a script, but so far I can't even get it to do its default behavior. I'm not a coder of any kind :^/

Edit:
In case anyone else feels like looking at this. I'm looking at "Force Offsite Links to Open in a New Window " from this page linked above...
http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Linkmania!

I can't get the example to do the stated behavior, much less modify it. If it can be made to work, changing it from opening in a new window, to erroring out, or going to about:blank should be fairly easy.
 
Last edited:

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
The problem is he wants stuff to come in from the outside, but not allow the person to browse to the outside. IOW, embedded YouTube he wants, but he doesn't want the person to be able to click to YouTube. I'm playing around with a script, but so far I can't even get it to do its default behavior. I'm not a coder of any kind :^/

Edit:
In case anyone else feels like looking at this. I'm looking at "Force Offsite Links to Open in a New Window " from this page linked above...
http://commons.oreilly.com/wiki/index.php/Greasemonkey_Hacks/Linkmania!

I can't get the example to do the stated behavior, much less modify it. If it can be made to work, changing it from opening in a new window, to erroring out, or going to about:blank should be fairly easy.

You're exactly right, you understood my problem perfectly. YouTube and even ads can "come in", I just don't want those links to lead anywhere (i.e. disable them visually or redirect to something like localhost)....
 

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
No workable solutions so far..........
May have to go with a whitelist add-on or application to only allow connections to/from approved sites.

If anyone has fresh ideas to actually block navigation to sites outside the site I'm on... I'm all ears :)
 

manko

Golden Member
May 27, 2001
1,846
1
0
No workable solutions so far..........

Did you have a look at Greasemonkey scripting?

Here's a quick demo for Wikipedia. If you have the Greasemonkey addon installed, save this code to a text file and name it wiki_ext_link.user.js. Then drag that file onto Firefox and install it. You may have to restart the browser.

Then open a link like:
http://en.wikipedia.org/wiki/Anandtech

With this script installed, external links will be unclickable (scroll down to "References, External Links"). The external links don't work, but you can still click Wikipedia internal site links.

Code:
// ==UserScript==
// @name           Wikipedia external link stripper
// @namespace      http://userscripts.org/users/99999999
// @description    Disables external links
// @include        http://*.wikipedia.*
// @include        http://wikipedia.*
// @copyright      Nobody
// @version        1.0.0
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

function main() {
var links = document.evaluate("//a",document,null,6,null);
if(links.snapshotLength>0) for(var i=0; i<links.snapshotLength; i++) {
    a = document.createElement('a');
    a.href = links.snapshotItem(i).href;
    h = a.hostname;
    	if (h != location.hostname) {
            links.snapshotItem(i).removeAttribute('href');
    	}
    }
}

main();

document.addEventListener('DOMAttrModified', main, false);

This works for me. Should be enough to get you started with Google and the links I already posted above.
 
Last edited:

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
manko,

That's amazing. It works! This script, along with your detailed instructions, really does "glue" the user to the current domain and prevent them from abandoning it. Very cool. I'll see if I can replace hard-coded domain names ("wikipedia") with a variable representing the {current domain}.

Thanks again!
 

immattobrien

Junior Member
Mar 31, 2012
8
0
0
Did you have a look at Greasemonkey scripting?

Here's a quick demo for Wikipedia. If you have the Greasemonkey addon installed, save this code to a text file and name it wiki_ext_link.user.js. Then drag that file onto Firefox and install it. You may have to restart the browser.

Then open a link like:
http://en.wikipedia.org/wiki/Anandtech

With this script installed, external links will be unclickable (scroll down to "References, External Links"). The external links don't work, but you can still click Wikipedia internal site links.

Code:
// ==UserScript==
// @name           Wikipedia external link stripper
// @namespace      http://userscripts.org/users/99999999
// @description    Disables external links
// @include        http://*.wikipedia.*
// @include        http://wikipedia.*
// @copyright      Nobody
// @version        1.0.0
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

function main() {
var links = document.evaluate("//a",document,null,6,null);
if(links.snapshotLength>0) for(var i=0; i<links.snapshotLength; i++) {
    a = document.createElement('a');
    a.href = links.snapshotItem(i).href;
    h = a.hostname;
    	if (h != location.hostname) {
            links.snapshotItem(i).removeAttribute('href');
    	}
    }
}

main();

document.addEventListener('DOMAttrModified', main, false);

This works for me. Should be enough to get you started with Google and the links I already posted above.

Is this applicable for google crome user(like me) too?

Thanks for the tip!
 

manko

Golden Member
May 27, 2001
1,846
1
0
Last edited:

atreader

Member
Apr 28, 2010
95
0
0
Restricting people to limited sites usually creates bad user experience as they feel restricted.

You can maybe lookup on privoxy.org local proxy settings. Configure browser to use local proxy (privoxy). And in privoxy setup rules to only allow rendering particular sites/domains.

Greasemonkey script solution wise, I think it will be bit difficult or will take some more effort to block external sites than the white lists. A lot of sites add links dynamically (e.g. check Engadget.com discuz comments) Though all this depends on particular sites.
You will have to do something similar to AdBlock, which manipulates the page before its loaded in browser.

Links are not just <a> elements. In pages developer can attach links via javascript methods. <span onclick=javascript:fooFunction() >. Within fooFunction developer can add navigate the browser to a different website.

Maybe in greasemonkey script also add condition to match the (address bar URL) 'document.location.url contains [domain1 OR domain2 OR domain3....] logic. If the condition fails then navigate back to previous page.

Keep in mind, user can easily disable greasemonkey | add-on.

Most greasemonkey scripts work fine in Google Chrome.
 

Spacehead

Lifer
Jun 2, 2002
13,067
9,858
136
I am setting up a PC for someone who is only going to view the sites I put in the Bookmarks. They aren't interested in "surfing the Web", only in reading these specific sites. As such, anything that allows them to go "out" and fully surf the web is undesired.
"They aren't interested" or you don't want them going to outside sites?
If the former, are they unable to not click on links?