NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Youtube Comment History
// @namespace beitang.ca
// @match *://*.youtube.com/*
// @grant none
// @version 1.0
// @author Mr. B
// @description Add a link to comment history in Youtube profile menu
// @license MIT
// @run-at document-end
// ==/UserScript==
(() => {
'use strict'
const LINK_ELEM_ID = "my-comment-history"
function waitForMenu(callback) {
let interval = setInterval(() => {
const addedLink = document.querySelectorAll('#contentWrapper #channel-container #'+ LINK_ELEM_ID)[0]
if (!addedLink) {
const container = document.querySelectorAll('#contentWrapper #channel-container')[0]
if (container) {
clearInterval(interval)
callback(container)
}
}
else {
clearInterval(interval)
}
}, 100)
}
function addLink(container) {
const link = document.createElement("a")
link.setAttribute("href", 'https://myactivity.google.com/page?hl=en&page=youtube_comments')
link.setAttribute("target", "_blank")
link.setAttribute("id", LINK_ELEM_ID)
link.innerText = 'Comment History'
container.appendChild(link)
container.appendChild(document.createElement("br"))
}
document.body.addEventListener('click', () => waitForMenu(addLink))
})();