dancewiththesky's
CickenFillet
<
View Source
deviantEXPERIENCE:PowerMode
// ==UserScript== // @name deviantEXPERIENCE:PowerMode // @namespace com.deviantart.dancewiththesky // @description Adds key shortcuts to deviantART pages // @include http://*.deviantart.com/* // @exclude http://chat.deviantart.com/chat/* // @exclude http://www.deviantart.com/submit/* // @exclude http://mail.deviantart.com/* // @exclude http://portfolio.deviantart.com/* // @exclude http://my.deviantart.com/settings/identity* // @x-pkg-guid {b90fa88d-d623-40da-a4eb-7144f85a3139} // @x-pkg-version 0.2.3.3 // ==/UserScript== /* ==UpdateInfo== 0.2.3.3: Exclude identity settings. 0.2.3.2: Exclude portfolio management. 0.2.3.1: Exclude staff mail. 0.2.3: Detects Command key on Mac. New shorcut for one's gallery. 0.2.2.4: New Update URL. 0.2.2.3: Exclude submission page 0.2.2.2: Added new shorcut 'V' for your favourites. Minor enhancements. 0.2.2.1: Migrated to ChickenFillet and became compatible with Firefox 3. 0.2.2: Added a new shortcut key X for the devWATCH list management page. Fixed a bug that made the extension interfere with Staff shortcuts. Disabled the extension from working inside dAmn chat rooms. 0.2.1: Fixed a bug that made the extension interfere with Firefox default shortcuts. ==/UpdateInfo== */ (function(){ const DEVIANT_NAME = unsafeWindow.deviantART? unsafeWindow.deviantART.deviant.username : null; var KEY_MAPPING = { 'I' : ["deviantART front page (
i
ndex)", "http://www.deviantart.com/"], 'T' : ["
T
oday", "http://today.deviantart.com/"], 'F' : ["
F
orum", "http://forum.deviantart.com/"], 'H' : ["
H
elp & FAQ", "http://help.deviantart.com/"], 'R' : ["
R
andom deviant", "http://www.deviantart.com/random/deviant"], 'D' : ["Random
d
eviation", "http://www.deviantart.com/random/deviation"] }; if (DEVIANT_NAME){ var m = { // shortcuts that requires deviant to be logged in 'P' : ["Your
p
rofile", "http://" + DEVIANT_NAME + ".deviantart.com" ], 'M' : ["Your
m
essage center", "http://my.deviantart.com/messages/"], 'G' : ["Your
g
allery", "http://" + DEVIANT_NAME + ".deviantart.com/gallery"], 'J' : ["Your
j
ournal management", "http://my.deviantart.com/journal/"], 'N' : ["Your
n
otes", "http://my.deviantart.com/notes/"], 'W' : ["Your deviant
W
ATCH", "http://my.deviantart.com/messages/#view=deviations"], 'X' : ["Manage your devWATCH list", "http://my.deviantart.com/deviants/"], 'V' : ["Your fa
v
uorites", "http://" + DEVIANT_NAME + ".deviantart.com/favourites/" ], 'S' : ["
S
ubmission page", "http://www.deviantart.com/submit/"] }; for(var k in m){ KEY_MAPPING[k] = m[k]; } } function fromSafeTarget(keyEvent){ var targetTag = keyEvent.target.tagName.toLowerCase(); return ( !keyEvent.altKey && !keyEvent.ctrlKey && !keyEvent.metaKey && targetTag != "textarea" && targetTag != "select" && targetTag != "input" ); } function getKey(keyEvent){ if (keyEvent.which > 65 && keyEvent.which < 90){ return String.fromCharCode(keyEvent.keyCode); } } function run(){ // create a hidden shortcut list var shortCutList = document.createElement('div'); shortCutList.id = '__powermode-shortcutList'; shortCutList.setAttribute('style', 'background-color: #374341; opacity: 0.95; position: fixed; top: 100px; width: 400px; padding: 20px; border-width: 1px; border-color: white; border-style: solid; color: white; z-index: 60; display: none;'); shortCutList.style.left = (window.innerWidth/2) - (400/2) + "px"; var listCode = "
PowerMode Shortcut List
"; // add login notice if(!DEVIANT_NAME){ listCode += "
Please log in to enable" + " all supported shortcuts
"; } for(k in KEY_MAPPING){ if (k == 'P'){ // start of 'my' shortcuts listCode += "
"; } listCode += "
" + k + "
" + KEY_MAPPING[k][0] + "
"; } // add L listCode += "
"; listCode += "
L
Show key shortcut
l
ist.
"; shortCutList.innerHTML = listCode; document.body.appendChild(shortCutList); document.addEventListener('keydown', function(e){ if (fromSafeTarget(e)) { var k = getKey(e); if (k == 'L'){ shortCutList.style.display = "block"; } else if (KEY_MAPPING[k]){ window.location.href = KEY_MAPPING[k][1]; } } }, false); document.addEventListener('keyup', function(e){ if (fromSafeTarget(e) && getKey(e) == 'L'){ shortCutList.style.display = "none"; } }, false); } run(); })();
Tastefully Powered by ChickenFillet