ao3 navigation and lazy tweaks

tumblr style keyboard nav for AO3

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        ao3 navigation and lazy tweaks
// @author	    theaeblackthorn
// @namespace	http://noseyhedgehog.co.uk
// @description tumblr style keyboard nav for AO3
// @include     http://archiveofourown.org/*
// @include     https://archiveofourown.org/*
// @include     http://*.archiveofourown.org/*
// @include     https://*.archiveofourown.org/*
// @version     1.5
// @grant       none
// ==/UserScript==


jQuery.noConflict();

jQuery(document).ready ( function() 
{
    var username = 'theaeblackthorn'; // CHANGE THIS TO YOUR USERNAME

    if(jQuery('p.kudos a[href^="/users/'+username+'"]').length > 0 )  
    {
        jQuery('.work.meta').css('background-color', '#E5FCC2');
    }


    jQuery(document).on('keydown', function (e) { 
    
        if(!jQuery('textarea').is(":focus") && !jQuery('input').is(":focus")){

            if(e.which == 83 )// if 's' hit, subscribe to this fic
            {
                if (jQuery('#new_subscription').length > 0)
                {
                    jQuery('#new_subscription').submit();
                }
            }
            if(e.which == 75)// if 'k' hit, give this fic kudos
            {
                if (jQuery('#new_kudo').length > 0)
                {
                    jQuery('#new_kudo').submit();
                }
            }
            if(e.which == 77)// if 'm' hit, mark this fic to read later
            {
                var location = jQuery('li.mark a').attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
            }
            if(e.which == 68 )// if 'd' hit, download the mobi version of this
            {
                var location = jQuery('li.download .secondary a').first().attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
            }
            if(e.which == 163 )// if # selected, set to view complete only & english and reload page
            {
                jQuery('#work_search_language_id').val('1');
                var complete_status = jQuery('#work_search_complete').prop('checked');
                 jQuery('#work_search_complete').prop('checked', !complete_status );
                 jQuery('#work_filters').submit();
            }
        
            if(e.which == 37)  // left
            {
             //   alert(location);
               // jQuery('li.previous a').css('background-color','purple');
    
                var location = jQuery('li.previous a').attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
                
            } else if(e.which == 39)  // right
            {   
                var location = jQuery('li.next a').attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
            } else if(e.which == 66)  // if b selected, bookmark the fic
            {   
                jQuery('#bookmark-form form').submit();
                
            } else if(e.which == 87)  // if w selected, show entire fic, not chapters
            {   
                var location = jQuery('li.entire a').attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
                
            } else if(e.which == 67)  // if c selected, show chapters, not entire fic
            {   
                var location = jQuery('li.bychapter a').attr('href');
                if (location!==null)
                {
                    window.location.href = location;
                }
                
            }  
        
        }
    });
 



});