Online Document Viewer

Open documents in Google docs!

  1. // ==UserScript==
  2. // @name Online Document Viewer
  3. // @namespace Online Document Viewer
  4. // @match *://*/*
  5. // @grant none
  6. // @version 1.0
  7. // @author K.D.
  8. // @description Open documents in Google docs!
  9. // ==/UserScript==
  10.  
  11. let drive= "https://docs.google.com/viewer?url=",
  12. regex= /.+\.pdf|\.doc|\.docx|\.xls|\.xlsx|\.ppt|\.pptx/i;
  13.  
  14. function main(a){
  15.  
  16. a.onclick=()=>{
  17. if(regex.test(a.href)){
  18. location.href= drive + a.href;
  19. return false;
  20. }
  21. else{
  22. location.href= a.href;
  23. return false;
  24. }
  25. };
  26. }
  27.  
  28. let google= /google\..+?\/search\?q=/i;
  29. if(google.test(location.href)){
  30. let gLinks= document.querySelectorAll(".Zu0yb.UGIkD.qzEoUe");
  31. gLinks.forEach(link => {
  32. let gURL= link.closest("a");
  33. gURL.removeAttribute("ping");
  34. setInterval(main(gURL), 2000);
  35. });
  36. }
  37. else{
  38. let allLinks= document.querySelectorAll("a");
  39. allLinks.forEach(link => {
  40. setInterval(main(link), 2000);
  41. });
  42. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址