ao3 navigation and lazy tweaks

tumblr style keyboard nav for AO3

  1. // ==UserScript==
  2. // @name ao3 navigation and lazy tweaks
  3. // @author theaeblackthorn
  4. // @namespace http://noseyhedgehog.co.uk
  5. // @description tumblr style keyboard nav for AO3
  6. // @include http://archiveofourown.org/*
  7. // @include https://archiveofourown.org/*
  8. // @include http://*.archiveofourown.org/*
  9. // @include https://*.archiveofourown.org/*
  10. // @version 1.5
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14.  
  15. jQuery.noConflict();
  16.  
  17. jQuery(document).ready ( function()
  18. {
  19. var username = 'theaeblackthorn'; // CHANGE THIS TO YOUR USERNAME
  20.  
  21. if(jQuery('p.kudos a[href^="/users/'+username+'"]').length > 0 )
  22. {
  23. jQuery('.work.meta').css('background-color', '#E5FCC2');
  24. }
  25.  
  26.  
  27. jQuery(document).on('keydown', function (e) {
  28. if(!jQuery('textarea').is(":focus") && !jQuery('input').is(":focus")){
  29.  
  30. if(e.which == 83 )// if 's' hit, subscribe to this fic
  31. {
  32. if (jQuery('#new_subscription').length > 0)
  33. {
  34. jQuery('#new_subscription').submit();
  35. }
  36. }
  37. if(e.which == 75)// if 'k' hit, give this fic kudos
  38. {
  39. if (jQuery('#new_kudo').length > 0)
  40. {
  41. jQuery('#new_kudo').submit();
  42. }
  43. }
  44. if(e.which == 77)// if 'm' hit, mark this fic to read later
  45. {
  46. var location = jQuery('li.mark a').attr('href');
  47. if (location!==null)
  48. {
  49. window.location.href = location;
  50. }
  51. }
  52. if(e.which == 68 )// if 'd' hit, download the mobi version of this
  53. {
  54. var location = jQuery('li.download .secondary a').first().attr('href');
  55. if (location!==null)
  56. {
  57. window.location.href = location;
  58. }
  59. }
  60. if(e.which == 163 )// if # selected, set to view complete only & english and reload page
  61. {
  62. jQuery('#work_search_language_id').val('1');
  63. var complete_status = jQuery('#work_search_complete').prop('checked');
  64. jQuery('#work_search_complete').prop('checked', !complete_status );
  65. jQuery('#work_filters').submit();
  66. }
  67. if(e.which == 37) // left
  68. {
  69. // alert(location);
  70. // jQuery('li.previous a').css('background-color','purple');
  71. var location = jQuery('li.previous a').attr('href');
  72. if (location!==null)
  73. {
  74. window.location.href = location;
  75. }
  76. } else if(e.which == 39) // right
  77. {
  78. var location = jQuery('li.next a').attr('href');
  79. if (location!==null)
  80. {
  81. window.location.href = location;
  82. }
  83. } else if(e.which == 66) // if b selected, bookmark the fic
  84. {
  85. jQuery('#bookmark-form form').submit();
  86. } else if(e.which == 87) // if w selected, show entire fic, not chapters
  87. {
  88. var location = jQuery('li.entire a').attr('href');
  89. if (location!==null)
  90. {
  91. window.location.href = location;
  92. }
  93. } else if(e.which == 67) // if c selected, show chapters, not entire fic
  94. {
  95. var location = jQuery('li.bychapter a').attr('href');
  96. if (location!==null)
  97. {
  98. window.location.href = location;
  99. }
  100. }
  101. }
  102. });
  103.  
  104.  
  105.  
  106. });