Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

some JavaScript for detecting dangerous links

Featured Replies

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?

ixfd64.png

 

ARENAscape:

 

Baratus [AS] max hit: 166 with Moon Battle Hammer

ixfd64 [AS] max hit: 116 with (untitled spell #2)

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.

gladz.png

Proud Retired Council of The Gladiatiorz

Click here for our website - 110+ F2P Combat Requirements

  • Author

Hmm, that's very odd.

 

 

 

Also, if your GeoCities signature doesn't work, it's because GeoCities does not allow hotlinking.

ixfd64.png

 

ARENAscape:

 

Baratus [AS] max hit: 166 with Moon Battle Hammer

ixfd64 [AS] max hit: 116 with (untitled spell #2)

Nice idea ixfd; and a rather solid warning, more than just the censored text.

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.

nh.jpg
  • Author

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.

ixfd64.png

 

ARENAscape:

 

Baratus [AS] max hit: 166 with Moon Battle Hammer

ixfd64 [AS] max hit: 116 with (untitled spell #2)

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.

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

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.