AWS shortcut keys

AWS navigation shortcut keys

Versión del día 20/8/2020. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name     AWS shortcut keys
// @description AWS navigation shortcut keys
// @include  http*://*aws.amazon.com/*
// @version  1.00
// @grant    none
// @namespace https://greasyfork.dpdns.org/users/304483
// ==/UserScript==

// Based on this example:
// https://greasyfork.dpdns.org/en/scripts/2656-facebook-logout-shortcut-just-press-alt-l/code

var eventUtility = {
    addEvent : function(el, type, fn) {
        if (typeof addEventListener !== "undefined") {
            el.addEventListener(type, fn, false);
        } else if (typeof attachEvent !== "undefined") {
            el.attachEvent("on" + type, fn);
        } else {
            el["on" + type] = fn;
        }
    }
};

function ascii (a) { return a.charCodeAt(0); }

function getClassElementWithTitle(doc, classname, title)
{
  var items = doc.getElementsByClassName(classname);
  
  for (i = 0; i < items.length; i++)
  {
    if (items[i].title == title)
      return items[i];
  }
  return null;  
}

function checkForRefreshShortcut(altKey, code)
{
  // ALT + R = Click 'refresh' button/link in page
  if (altKey && code === ascii('R'))
  {
    var refreshBtn = getClassElementWithTitle(window.frames[0].document, 'gwt-Image', 'Refresh');
    if (refreshBtn)
      refreshBtn.click();
  }    
}


(function() {
  
  // BASE FRAME EVENT HANDLER
  // ========================
	eventUtility.addEvent(document, "keydown",
		function(evt) {
			var code = evt.keyCode,
			altKey = evt.altKey;
    	shiftKey = evt.shiftKey;
      
      // ALT + / = Go to search box
			if (altKey && code === 191)
      {
				var searchfield = document.getElementById("search-box-input");
        searchfield.focus()
        searchfield.select()
      }
    
      checkForRefreshShortcut(altKey, code);
    
      // ALT + S = 'Services' menu
    	if (altKey && code === ascii('S'))
      {
        var services = document.getElementById("nav-servicesMenu");
        services.click();
        evt.preventDefault();
      }
		});
  
  // IFRAME EVENT HANDLER
  // ====================
  eventUtility.addEvent(window.frames[0].document, "keydown",
  	function(evt) {
    	var code = evt.keyCode,
      altKey = evt.altKey;
      shiftKey = evt.shiftKey;

      checkForRefreshShortcut(altKey, code);
  	});
  
}());
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元