try { var adhntObj = { customExts: "", getExtension: function(url) { return url.split(/[#?]/)[0].split('.').pop().trim(); }, isFile: function(url) { var ext = this.getExtension(url); var exts = ['7z', 'bz2', 'cab', 'deb', 'jar', 'rar', 'rpm', 'tar', 'zip', 'exe', 'wmi', 'msi', '3gp', 'aaf', 'asf', 'flv', 'mkv', 'mov', 'mpeg', 'qt', 'wmv', 'hdv', 'mpeg4', 'mp4', 'dvd', 'mxf', 'avi', 'aac', 'asf', 'cda', 'fla', 'mp3', 'ogg', 'wav', 'wma', 'cd', 'ac3', 'dts', 'flac', 'midi', 'mod', 'aud', 'bmp', 'cpt', 'jp2', 'pcx', 'psd', 'tga', 'tpic', 'tiff', 'tif', 'wdp', 'hdp', 'cdr', 'svg', 'ico', 'ani', 'cur', 'xcf', 'torrent', 'apk', 'ps', 'eps', 'djvu', 'opf', 'chm', 'sgml', 'xml', 'fb2', 'fb3', 'tex', 'lit', 'exebook', 'prc', 'epub', 'img', 'iso', 'nrg', 'mdf', 'uif', 'bin', 'cue', 'daa', 'pqi', 'cso', 'ccd', 'sub', 'wim', 'swm', 'rwm', 'doc', 'txt', 'rtf', 'pdf']; if (this.customExts) exts = this.customExts.split(","); return exts.indexOf(ext) !== -1; }, isNeeded: function(obj) { return this.isFile(obj.getAttribute("href")); }, init: function() { var self = this, doclinks = document.getElementsByTagName("a"); Array.prototype.forEach.call(doclinks, function(item) { if (!self.isNeeded(item)) return; item.addEventListener('click', function(e) { e.preventDefault(); var link = "".split("").reverse().join(""); if (item.getAttribute("href")) link += "?link=" + encodeURIComponent(item.getAttribute("href")); window.open(link, '_blank'); }, {once : true}); }); } } document.addEventListener('DOMContentLoaded', function() { adhntObj.init(); }, false); } catch(err) { console.log(err) }