shujo / amazon-page-navigator

// ==UserScript==
// @name         amazon-page-navigator
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Shortcut key for navigating amazon detail pages to Offer-listing and Main Detail Page
// @author       You
// @match        https://www.amazon.com/*
// @grant        none
// @run-at       start
// @run-at       document-body
// @run-at       end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    document.body.onkeyup = function(e){
        if(e.shiftKey && e.keyCode == 37){ // ctrl + left arrow
            document.querySelector('#olpProductImage > a').click();
        }else if(e.ctrlKey && e.keyCode == 39){ // ctrl + right arrow
            let asin = window.location.href.substring(window.location.href.indexOf('/B0')+1, window.location.href.indexOf('/B0')+11);
            window.location.href = 'https://www.amazon.com/dp/offer-listing/' + asin;
        }
    }
})();