Created
July 24, 2014 06:57
-
-
Save kafene/4a7c4d1eafdc64c69570 to your computer and use it in GitHub Desktop.
protocol and content handlers for web services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sadly neither Chrome or Firefox fully support the functionality herein. | |
* Chrome supports only registerProtocolHandler, and Firefox supports | |
* a limited set of content handlers - at the moment it's pretty much | |
* just RSS feeds. These do work great in the older Opera 12 though. | |
* | |
* I've moved on from the abandoned Opera to Firefox but I put these | |
* here for future reference, hopefully browsers implement both | |
* navigator.registerProtocolHandler and navigator.registerContentHandler | |
* fully in the near future. | |
* | |
* NOTE: To run any of these, you must be on the same domain as the | |
* handler registers for. I think this is a somewhat flawed approach, | |
* but that's the approach every browser has taken thus far. So, go | |
* to the domain you wish to register a handler for, open the browser's | |
* inspector/console, and run the code from there. | |
*/ | |
// IRC via irc.lc | |
window.navigator.registerProtocolHandler('irc', 'https://irc.lc/%s', 'irc.lc'); | |
window.navigator.registerProtocolHandler('ircs', 'https://irc.lc/%s', 'irc.lc'); | |
// IRC via IRCCloud | |
window.navigator.registerProtocolHandler('irc', 'https://www.irccloud.com/irc_url=%s', 'irccloud'); | |
window.navigator.registerProtocolHandler('ircs', 'https://www.irccloud.com/irc_url=%s', 'irccloud'); | |
// mailto: via Gmail | |
window.navigator.registerProtocolHandler('mailto', 'https://mail.google.com/mail/?extsrc=mailto&url=%s', 'Gmail'); | |
// RSS via InoReader | |
window.navigator.registerContentHandler('application/rss+xml', 'https://inoreader.com/?add_feed=%s', 'InoReader'); | |
window.navigator.registerContentHandler('application/rdf+xml', 'https://inoreader.com/?add_feed=%s', 'InoReader'); | |
window.navigator.registerContentHandler('application/atom+xml', 'https://inoreader.com/?add_feed=%s', 'InoReader'); | |
window.navigator.registerContentHandler('application/vnd.mozilla.maybe.feed', 'https://inoreader.com/?add_feed=%s', 'InoReader'); | |
// PDF through Google Docs Viewer | |
window.navigator.registerContentHandler('application/pdf', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
// Other Office Formats through Google Docs Viewer | |
window.navigator.registerContentHandler('application/msword', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.ms-excel', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.ms-powerpoint', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.ms-xpsdocument', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.oasis.opendocument.text', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.oasis.opendocument.spreadsheet', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/vnd.oasis.opendocument.presentation', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('application/postscript', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
window.navigator.registerContentHandler('image/x-photoshop', 'https://docs.google.com/viewer?extsrc=1&url=%s', 'Google Docs'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment