Last active
July 29, 2021 10:33
-
-
Save leobm/6388710fa6c96b6ae1fa783015209e10 to your computer and use it in GitHub Desktop.
Delete youtube comments activity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Delete youtube comments activity | |
// @version 1 | |
// @grant none | |
// @include https://myactivity.google.com/page* | |
// ==/UserScript== | |
const DELETE_MAX_ENTRIES_AFTER_PAGE_RELOAD = 1; | |
(function(d) { | |
if (/\bpage=youtube_comments\b/.test(location.search)) { | |
var deleteButtons = []; | |
var youtubeImgs = query(d, 'img[src="https://www.gstatic.com/images/branding/product/2x/youtube_24dp.png"]'); | |
for (var i=0, max=youtubeImgs.length; i < max; i++) { | |
var btnContainer = youtubeImgs[i].parentNode.parentNode.parentNode; | |
var deleteButton = query(btnContainer, 'button')[0]; | |
deleteButtons.push(deleteButton); | |
} | |
for (var i=0; i < DELETE_MAX_ENTRIES_AFTER_PAGE_RELOAD; i++){ | |
deleteButtons[i].click(); | |
} | |
} | |
function query(startNode, selector) { | |
try { | |
var nodes = Array.prototype.slice.call( | |
startNode.querySelectorAll(selector)); | |
return nodes; | |
} catch(e){} | |
return []; | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment