Intercepting file download in chrome
Here is a little JS snippet which prevents every file download (and accessorily opens a new tab in Gsuite for attempts to download from the Gsuite):
chrome.downloads.onCreated.addListener(downloadItem => {
chrome.downloads.cancel( downloadItem.id, ()=>{
alert("DL canceled: "+downloadItem.finalUrl);
if (downloadItem.finalUrl.search("https://docs.google.com")!=-1){
var _driveUrl = downloadItem.finalUrl.replace(/export\?.*/,"");
chrome.tabs.create({url:_driveUrl}, ()=>{});
}
})
});
Comments
Post a Comment