Skip to content

Instantly share code, notes, and snippets.

@AsamiKafune
Created May 6, 2024 08:02
Show Gist options
  • Save AsamiKafune/8c5ffa596110f78e59450bff69cf4412 to your computer and use it in GitHub Desktop.
Save AsamiKafune/8c5ffa596110f78e59450bff69cf4412 to your computer and use it in GitHub Desktop.
/*
How to use
-- paste this script to console (f12)
credits
@asamikafune
*/
let fixedElement = document.getElementsByClassName("ytp-left-controls")[0];
const custom_button = `<button onclick="_copy()" id="al_text" style="margin-left: 10px; min-width: 70px; color:white;" class="ytp-button">คัดลอกเวลา</button>`
function _copy() {
let _ts = document.getElementsByClassName("ytp-time-current")[0].innerText;
if(_ts.split(":")[0].lenght == 1) _ts = "0"+_ts;
navigator.clipboard.writeText(_ts);
document.getElementById("al_text").innerText = "สำเร็จ";
setTimeout(() => {
document.getElementById("al_text").innerText = "คัดลอกเวลา";
}, 500);
}
let __ = document.createElement("script");
__.textContent = "(" + _copy.toString() + ")();";
document.head.appendChild(__);
fixedElement.insertAdjacentHTML('beforeend', custom_button);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment