Last active
September 12, 2017 17:45
-
-
Save noromanba/539e4359fc9ea287fb49d930a4eac6c5 to your computer and use it in GitHub Desktop.
avoid accidental remove on mixcloud.com for UserScript
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 Hey MC! (un) [x] it out | |
// @namespace https://noromanba.github.com | |
// @description avoid accidental remove on mixcloud.com for UserScript | |
// @include *://*.mixcloud.com/* | |
// @grant none | |
// @noframes | |
// @run-at document-end | |
// @version 2017.9.12.0 | |
// @homepage https://gist.github.com/noromanba/539e4359fc9ea287fb49d930a4eac6c5 | |
// @downloadURL https://gist.github.com/noromanba/539e4359fc9ea287fb49d930a4eac6c5/raw/mc-un-check-it-out.user.js | |
// @license MIT License https://nrm.mit-license.org/2017 | |
// @author noromanba https://noromanba.github.com | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/White_checkbox-checked.svg/512px-White_checkbox-checked.svg.png | |
// ==/UserScript== | |
// Icon (CC0 Univ PD by Offnfopt) | |
// https://commons.wikimedia.org/wiki/File%3AWhite_checkbox-checked.svg | |
// Devel | |
// https://gist.github.com/noromanba/539e4359fc9ea287fb49d930a4eac6c5 | |
(() => { | |
'use strict'; | |
if (!location.hostname.endsWith('mixcloud.com')) return; | |
const LOGIN_ID = document.body.querySelector([ | |
'header .user-name', | |
]); | |
if (!LOGIN_ID || !LOGIN_ID.textContent) return; | |
const hide = () => { | |
// MixCloud avoid accidental history removing | |
// https://www.mixcloud.com/dashboard/favorites/ | |
// https://www.mixcloud.com/<ACCOUNT_ID>/ | |
// https://www.mixcloud.com/<ACCOUNT_ID>/listens/ | |
const whitelist = [ | |
'/dashboard/listen-later/', | |
]; | |
whitelist.forEach(white => { | |
if (location.pathname.startsWith(white)) return; | |
Array.from(document.body.querySelectorAll([ | |
'.can-delete.cf.card .remove-fave', | |
//]), close => close.remove()); | |
]), close => close.style.visibility = 'hidden'); | |
}); | |
}; | |
hide(); | |
new MutationObserver(records => { | |
records.forEach(record => { | |
hide(record.target); | |
}); | |
}).observe(document.body, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment