Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let
- links= document.querySelectorAll("a"),
- drive= "https://docs.google.com/viewer?url=",
- regex= /.+\.pdf|\.doc|\.docx|\.xls|\.xlsx|\.ppt|\.pptx/i;
- links.forEach(link => {
- link.removeAttribute("ping");
- if (regex.test(link.href)){
- link.onclick=()=>{
- location.href= drive + link.href;
- return false;
- };
- }
- });
- //--------------
- let
- links= document.querySelectorAll("a"),
- drive= "https://docs.google.com/viewer?url=",
- regex= /.+\.pdf|\.doc|\.docx|\.xls|\.xlsx|\.ppt|\.pptx/i;
- links.forEach(link => {
- if (regex.test(link.href)){
- if (location.hostname=="google.com"){
- let
- gurl= encodeURIComponent(link),
- gpar= new URLSearchParams(gurl),
- url= gpar.get('url');
- link.href= drive + url;
- }
- else{
- link.href= drive + link.href;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement