Copy to clipboard button for Google Drive files
A better file viewer than the one Google provides, that's more suitable for displaying code and text files, with a Copy to clipboard button as well — great when using mobile devices that only offer Select All functionality for editable text. Go to Apps Script in your Google account Click New project in the upper left corner In the code editor, replace everything with the following: function doGet(e) { const id = "FILE_ID"; const file = DriveApp.getFileById(id); const contents = file.getBlob().setContentType("text/plain").getDataAsString(); const html = `<!DOCTYPE html> <html> <head> <base target="_top"> <style> :root { color-scheme: light dark; } pre { overflow-wrap: break-word; white-space: pre-wrap; } </style> </head> <body> <button id="copy">Copy to clipboar...