Skip to content

Instantly share code, notes, and snippets.

@torsten
Created January 31, 2011 20:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torsten/804702 to your computer and use it in GitHub Desktop.
Save torsten/804702 to your computer and use it in GitHub Desktop.
Greasemonkey script, enables Google Chrome to handle .URL files.
// ==UserScript==
// @name .URL file opener for Google Chrome
// @namespace http://torstenbecker.eu/
// @match file://*.URL
// @match file://*.url
// @author Torsten Becker
// @description Enables Chrome to handle .URL files (internet shortcuts, usually created on Windows) and navigates to their referenced location.
// ==/UserScript==
// Installation notes:
// 1. Use your operating system to associate Chrome with .URL files.
// 2. After installing in Chrome, go to Window => Extensions
// (or to chrome://extensions/) and check "Allow access to file URLs".
(function () {
var invalid = 'Invalid .URL file: ';
var content = document.body.innerHTML;
var urlLoc = content.indexOf('URL=');
if(urlLoc == -1)
{
alert(invalid + 'Does not contain a URL= line.');
return;
}
var nlLoc = content.indexOf("\n", urlLoc);
if(nlLoc < urlLoc + 8)
{
alert(invalid + 'Could not determine end of URL.');
return;
}
document.location = content.slice(urlLoc + 4, nlLoc);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment