ixfd64 Posted October 22, 2007 Share Posted October 22, 2007 As we know, certain files with extensions like .swf and [Caution: Executable File] are considered dangerous. To protect users, the extensions are "censored" such that users must manually type in the URL. True, many [Caution: Executable File] files and such are dangerous, but there are also many legitimate files (such as software updates). Because the URLs are censored, many users may not be smart enough to determine what the censored URLs are. I think that the best solution would not be to censor the links, but to add some sort of warning. I wrote some JavaScript to do just that: /* Script: File Extension Guardian v1.1 Author: Danny Chia (dannychia [at] berkeley.edu) Description: There are some malicious users that will post dangerous links on forums in hopes that someone will click them. This script is designed to remind users that clicking certain links can be dangerous, although it does not actually prevent them from accessing the links. Usage: This script should be placed at the bottom of the page. Since HTML is parsed from top to bottom, some elements of the script (such as document.links.length) may not work properly if the script is placed anywhere else. License: This script is available under the terms of the GNU Free Documentation License (GFDL) and may be freely modified or distributed. */ // counts links on page var c = document.links.length; // creates array for storing URLs var ar = new Array(c); // potentially dangerous extensions var badExt = new Array("ade", "adp", "bas", "bat", "cmd", "com", "exe", "lnk", "mdb", "mde", "pif", "scr", "shs", "swf", "vbs", "vb", "vbe", "ws", "wsc", "wsf", "wsh", "zip"); // activates confirmation system if there are links function init() { if (c > 0) { checkLinks(); } } // checks for potentially dangerous links function checkLinks() { for (var i = 0; i < c; i++) { ar[i] = document.links[i].href; for (var j = 0; j < badExt.length; j++) { if (ar[i].substring(ar[i].length - 3, ar[i].length) == badExt[j] || ar[i].substring(ar[i].length - 2, ar[i].length) == badExt[j]) { document.links[i].href = "javascript:confirmLink(" + i + ", '" + badExt[j] + "')"; } } } } // generates confirmation dialog function confirmLink(linkID, ext) { var msg = new Array("Caution: You are attempting to access a file with ", "the '." + ext + "' extension. Files with this extension may contain ", "content that is harmful to your computer. The URL of the page is ", "provided below:\n\n" + ar[linkID], "\n\nAre you sure you want to access this file?"); var confirmed = confirm(msg[0] + msg[1] + msg[2] + msg[3] + msg[4]); if (confirmed) { window.location = ar[linkID]; } } //starts script document.onLoad = init(); The source code is here: http://geocities.com/dchia1010/checkLinks.txt To see the script in action, go here: http://geocities.com/dchia1010/js-test.html What do you guys think? ARENAscape: Baratus [AS] max hit: 166 with Moon Battle Hammer ixfd64 [AS] max hit: 116 with (untitled spell #2) Link to comment Share on other sites More sharing options...
mrmyk Posted October 22, 2007 Share Posted October 22, 2007 I'm suprised. The last time i tried to upload a signature with geocities it said exactly what you are trying implement but it seems to be working fine for you at the bottom. Proud Retired Council of The GladiatiorzClick here for our website - 110+ F2P Combat Requirements Link to comment Share on other sites More sharing options...
ixfd64 Posted October 22, 2007 Author Share Posted October 22, 2007 Hmm, that's very odd. Also, if your GeoCities signature doesn't work, it's because GeoCities does not allow hotlinking. ARENAscape: Baratus [AS] max hit: 166 with Moon Battle Hammer ixfd64 [AS] max hit: 116 with (untitled spell #2) Link to comment Share on other sites More sharing options...
____ Posted October 22, 2007 Share Posted October 22, 2007 Nice idea ixfd; and a rather solid warning, more than just the censored text. Link to comment Share on other sites More sharing options...
mchainmail Posted October 22, 2007 Share Posted October 22, 2007 I don't know if this is possible, but could you add a delay before you can hit okay? Like the warning has to be on screen for 5 seconds or something. Link to comment Share on other sites More sharing options...
ixfd64 Posted October 22, 2007 Author Share Posted October 22, 2007 It might be possible, but I'm not that experienced with JavaScript. :lol: If it's possible, it will probably have to use a new function instead of JavaScript's built-in confirm() function. ARENAscape: Baratus [AS] max hit: 166 with Moon Battle Hammer ixfd64 [AS] max hit: 116 with (untitled spell #2) Link to comment Share on other sites More sharing options...
Adam007 Posted October 22, 2007 Share Posted October 22, 2007 Nice work. Especially useful for the occasion where someone puts up a legitimate link, lets the thread grow a few pages, then replaces it with a bad one. Link to comment Share on other sites More sharing options...
Errdoth Posted October 22, 2007 Share Posted October 22, 2007 It might be possible, but I'm not that experienced with JavaScript. :lol: If it's possible, it will probably have to use a new function instead of JavaScript's built-in confirm() function. it'd be easily done with a window.setTimeout Last.fm Signature Overlays Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now