Created
June 27, 2013 17:02
-
-
Save pastak/5878230 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name PresserSelectFeedByNumber | |
| // @namespace userjs.com.cosmio.pastak | |
| // @description Presserにショートカットキーとかを追加します。 | |
| // @include http://feedpresser.com/* | |
| // ==/UserScript== | |
| /** 使い方 ** | |
| * a:前のフィードの一覧を表示 | |
| * s:次のフィードの一覧を表示 | |
| * q:右下に現れる入力欄にエントリータイトルの横の数字を入力しエンターをすると、その記事を表示させる。 | |
| */ | |
| (function(d,func){ | |
| //こう書かないとChromeで動くuser.jsでjQueryを使えない… | |
| //参考:http://www.otchy.net/20110607/use-jquery-on-greasemonkey-for-chrome/ | |
| var h = d.getElementsByTagName('head')[0]; | |
| var s1 = d.createElement("script"); | |
| s1.setAttribute("src", "http://code.jquery.com/jquery-2.0.2.min.js"); | |
| s1.addEventListener('load', function() { | |
| var s2 = d.createElement("script"); | |
| s2.textContent = "jQuery.noConflict();(" + func.toString() + ")(jQuery);"; | |
| h.appendChild(s2); | |
| }, false); | |
| h.appendChild(s1); | |
| })(document,function(){ | |
| var selectNumKeyFunc = function(){ | |
| var i = setInterval(function(){ | |
| if($('#moreload').is(':visible')){ | |
| $('.show-blog-time').css({'left':'0px'}); | |
| //フィードごとに数字を割り当てる | |
| $('.show-blog-cell').each(function(i){ | |
| $(this).attr('id',('cell'+i)).find('.show-blog-time').prepend($('<span>').text(i).css({ | |
| 'background-color':'#ffc0cb','color':'red','font-weight':'bold','margin':'3px','padding':'3px' | |
| })); | |
| }) | |
| $('body').append( | |
| $('<form>').submit(function(event){ | |
| event.preventDefault(); | |
| $('body').focus(); | |
| $(('#cell'+$('#jumpId').val())).click(); | |
| $('#jumpId').val('').hide(); | |
| return false; | |
| }).append( | |
| $('<input>').hide().attr('type','number').attr('id','jumpId').css({'width':'70px','font-size':'20px','position':'fixed','bottom':'5px','right':'10px','border':'none'}) | |
| ) | |
| ) | |
| clearInterval(i); | |
| } | |
| }) | |
| } | |
| $(document).shortcut({ | |
| 'q': function() { | |
| $('#jumpId').show().focus(); | |
| $('jumpId').val(''); | |
| }, | |
| 'a':function(){ | |
| //戻る | |
| //同一フォルダかどうか | |
| var selected = $('.blogselected'); | |
| var d_prev=selected.removeClass('blogselected').prev(); | |
| if(d_prev.length>0){ | |
| $(d_prev).addClass('blogselected').find('.blog').click(); | |
| }else{ | |
| $(selected).parents('div.side-folder').prev().find('.blogs>div').last().addClass('blogselected').find('.blog').click(); | |
| } | |
| }, | |
| 's':function(){ | |
| //進む | |
| var selected = $('.blogselected'); | |
| if(selected.length<1){ | |
| $('.blogs').first().find('div').first().addClass('blogselected').find('.blog').click(); | |
| return; | |
| } | |
| //同一フォルダかどうか | |
| var d_next=selected.removeClass('blogselected').next(); | |
| if(d_next.length>0){ | |
| $(d_next).addClass('blogselected').find('.blog').click(); | |
| }else{ | |
| $(selected).parents('div.side-folder').next().find('.blogs>div').last().addClass('blogselected').find('.blog').click(); | |
| } | |
| } | |
| }) | |
| $('.folder-title').click(selectNumKeyFunc); | |
| $('.blog').click(selectNumKeyFunc) | |
| $('.blogs').children('div').click(function(){ | |
| $('.blogselected').removeClass('blogselected'); | |
| $(this).addClass('blogselected'); | |
| }) | |
| $('#recommend').click(selectNumKeyFunc); | |
| $('#today-feed').click(selectNumKeyFunc); | |
| $('#all-feed').click(selectNumKeyFunc); | |
| selectNumKeyFunc(); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment