Shift + Scroll = HScroll

Scroll horizontally using < SHIFT + scroll > (useful in Firefox)

  1. // ==UserScript==
  2. // @name Shift + Scroll = HScroll
  3. // @namespace http://userscripts.org/users/303112
  4. // @description Scroll horizontally using < SHIFT + scroll > (useful in Firefox)
  5. // @version 1.2
  6. // @include *
  7. // @author Cezar Derevlean - www.dcezar.com - contact@dcezar.com
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. this.$ = this.jQuery = jQuery.noConflict(true);
  12.  
  13. // BEGIN plugins
  14.  
  15. /*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
  16. * Licensed under the MIT License (LICENSE.txt).
  17. *
  18. * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
  19. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
  20. * Thanks to: Seamus Leahy for adding deltaX and deltaY
  21. *
  22. * Version: 3.0.6
  23. *
  24. * Requires: 1.2.2+
  25. */
  26. /*
  27. ** Possible Additional Configuration:
  28. ** If, when you hold shift, you scroll through previous pages / history
  29. ** Go to about:config page in firefox and set the variable mousewheel.with_shift.action to 0
  30. ** If it still doesn't work and you are using a linux distribution go to linux's settings > windows > modifier for modified click actions (something like that) and change it to something other than shift
  31. ** Also if alt click to save isn't working on linux
  32. ** Go to about:config and set browser.altClickSave to true
  33. ** You may have to go in to linux window setting again to change alt key's action
  34. **
  35. ** I've been in this situation before so I added this comment
  36. ** I did not write any of the script myself
  37. ** Alkazaar, 23/07/2014
  38. */
  39.  
  40. ;(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
  41.  
  42. // END plugins
  43.  
  44.  
  45.  
  46. // BEGIN main
  47.  
  48. $(document).ready(function() {
  49. var pressed = false;
  50.  
  51. $(document).keydown(function (e) {
  52. if (e.keyCode == 16) {
  53. pressed = true;
  54. }
  55. });
  56. $(document).keyup(function(event){
  57. pressed = false;
  58. });
  59.  
  60. $('html, body, *').mousewheel(function(e, delta) {
  61. if (pressed) {
  62. this.scrollLeft -= (delta * 40);
  63. e.preventDefault();
  64. }
  65. });
  66.  
  67. });
  68.  
  69. // END main