I am trying to make a script for DeviantArt that clicks "Remove from notifications" when I press the delete key. Deviantart allows the user to follow artists and provides any new artwork under a common notification system. When you click some artwork from notifications there is a button on the right that lets the user remove that artwork from notifications.
Here is the code I've tried which isn't working.
// ==UserScript==
// @name Deviations remove shortcut
// @namespace DeviationsRemShortcut
// @include http://www.deviantart.com/art/*
// @include https://www.deviantart.com/art/*
// ==/UserScript==
(function(){
document.addEventListener('keydown', function(e) {
// pressed del
if (e.keyCode == 46 && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
document.querySelector(".remove-message-button").click(); // this will trigger the click event
}
}, false);
})();
When I manually enter document.querySelector(".remove-message-button").click(); into the console it works as expected.