Online Document Viewer

Open documents in Google docs!

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Online Document Viewer
// @namespace   Online Document Viewer
// @match       *://*/*
// @grant       none
// @version     1.0
// @author      K.D.
// @description Open documents in Google docs!
// ==/UserScript==

let drive= "https://docs.google.com/viewer?url=",
regex= /.+\.pdf|\.doc|\.docx|\.xls|\.xlsx|\.ppt|\.pptx/i;

function main(a){

a.onclick=()=>{
if(regex.test(a.href)){
   location.href= drive + a.href;
   return false;
}
else{
   location.href= a.href;
   return false;   
}
};    
}   

let google= /google\..+?\/search\?q=/i;
if(google.test(location.href)){
let gLinks= document.querySelectorAll(".Zu0yb.UGIkD.qzEoUe");
gLinks.forEach(link => {
let gURL= link.closest("a");
    gURL.removeAttribute("ping");
setInterval(main(gURL), 2000);
});
}
else{
let allLinks= document.querySelectorAll("a");
allLinks.forEach(link => {
setInterval(main(link), 2000);
});
}