Skip to content

Instantly share code, notes, and snippets.

@murrayinman
Last active October 13, 2022 16:17
Show Gist options
  • Save murrayinman/e841ddf6c8b8bcf5ca1978ada9683352 to your computer and use it in GitHub Desktop.
Save murrayinman/e841ddf6c8b8bcf5ca1978ada9683352 to your computer and use it in GitHub Desktop.
Adds a copy button to copy the file URL
// ==UserScript==
// @name Copy file URL in CA File Manager
// @namespace http://tampermonkey.net/
// @version 0.5
// @description Adds a copy button to copy the file URL
// @author Murray Inman
// @updateURL https://gist.github.com/murrayinman/e841ddf6c8b8bcf5ca1978ada9683352/raw/copyFileURLinCA.user.js
// @match https://riosalado.coursearc.com/file-manager*
// @match https://riosalado.coursearc.com/index.php/tools/required/files/properties*
// @grant GM_setClipboard
// ==/UserScript==
function boomCopy() {
var URLcell = document.querySelector(" body #ccm-file-properties table.ccm-grid tbody>tr:nth-of-type(3)>td[colspan]");
console.log(URLcell);
var fileURLtext = document.querySelector(" body #ccm-file-properties table.ccm-grid tbody>tr:nth-of-type(3)>td[colspan]").innerText;
console.log(fileURLtext);
var copyBtn = document.createElement('input');
copyBtn.type = "button";
copyBtn.id = "URLcopyBtn";
copyBtn.value = "📋 Copy URL";
copyBtn.onclick = (copyFunction());
copyBtn.style = "padding-inline:0.5em;margin-inline:0.5em;"
URLcell.appendChild(copyBtn);
// $(URLcell).append(
// ' <button style="padding:2px 3px;" onclick="copyFunction">&#128203; Copy URL</button>'
// );
function copyFunction() {
navigator.clipboard.writeText(fileURLtext);
}
var copiedText = navigator.clipboard.readText();
console.log(copiedText);
}
document.onload = boomCopy();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment