Skip to content

Instantly share code, notes, and snippets.

@jsejcksn
Last active June 9, 2018 23:30
Show Gist options
  • Save jsejcksn/c330b8814bfc3be4cbcf2d2b14c12451 to your computer and use it in GitHub Desktop.
Save jsejcksn/c330b8814bfc3be4cbcf2d2b14c12451 to your computer and use it in GitHub Desktop.
Display only YouTube Music items in My Activity
javascript:(()=>{'use strict';const items={cards:{all:document.querySelectorAll('div.fp-display-item-holder')},titles:{all:document.querySelectorAll('div.fp-display-item-title'),notMusic:[]}};for(let i=0;i<items.titles.all.length;i++){if(items.titles.all[i].textContent.trim()!=='YouTube Music'){items.titles.notMusic.push(items.titles.all[i]);}};for(let i=0;i<items.cards.all.length;i++){for(let j=0;j<items.titles.notMusic.length;j++){if(items.cards.all[i].contains(items.titles.notMusic[j])){items.cards.all[i].remove();}}};let s=document.createElement('style');s.textContent='div.fp-date-block-overflow {display:none}';document.head.appendChild(s);})();
// Navigate to the following URL (26 is YouTube) — https://myactivity.google.com/item?product=26
// Copy and paste this into your browser JS console each time new items load into view
{
'use strict';
const items = {
cards: {
all: document.querySelectorAll('div.fp-display-item-holder')
},
titles: {
all: document.querySelectorAll('div.fp-display-item-title'),
notMusic: []
}
}
// Populate non-YouTube Music titles
for (let i = 0; i < items.titles.all.length; i++) {
if (items.titles.all[i].textContent.trim() !== 'YouTube Music') {
items.titles.notMusic.push(items.titles.all[i]);
}
}
// Remove non-YouTube Music items
for (let i = 0; i < items.cards.all.length; i++) {
for (let j = 0; j < items.titles.notMusic.length; j++) {
if (items.cards.all[i].contains(items.titles.notMusic[j])) {
items.cards.all[i].remove();
}
}
}
let s = document.createElement('style');
s.textContent = 'div.fp-date-block-overflow {display: none}';
document.head.appendChild(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment