Replace 4chan's previous/next page.

This commit is contained in:
Nicolas Stepien 2011-06-24 20:45:05 +02:00
parent beede2108c
commit e0ceb3222f
2 changed files with 22 additions and 2 deletions

View File

@ -707,6 +707,8 @@
keybinds.previousReply = (key = $.getValue('key/previousReply', 0)).length ? key : 'K';
keybinds.nextThread = (key = $.getValue('key/nextThread', 0)).length ? key : 'n';
keybinds.previousThread = (key = $.getValue('key/previousThread', 0)).length ? key : 'p';
keybinds.nextPage = (key = $.getValue('key/nextPage', 0)).length ? key : 'alt+x';
keybinds.previousPage = (key = $.getValue('key/previousPage', 0)).length ? key : 'alt+z';
keybinds.openThreadTab = (key = $.getValue('key/openThreadTab', 0)).length ? key : 'o';
keybinds.openThread = (key = $.getValue('key/openThread', 0)).length ? key : 'O';
keybinds.expandThread = (key = $.getValue('key/expandThread', 0)).length ? key : 'e';
@ -720,7 +722,7 @@
},
cb: {
keydown: function(e) {
var kc, key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value;
var kc, key, o, qr, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2;
kc = e.keyCode;
if ((65 <= kc && kc <= 90)) {
key = String.fromCharCode(kc);
@ -808,6 +810,16 @@
case keybinds.hide:
threadHiding.toggle(thread);
break;
case keybinds.nextPage:
if ((_ref = $('input[value=Next]')) != null) {
_ref.click();
}
break;
case keybinds.previousPage:
if ((_ref2 = $('input[value=Previous]')) != null) {
_ref2.click();
}
break;
default:
return;
}
@ -1000,7 +1012,7 @@
var arr, checked, description, dialog, hiddenNum, hiddenThreads, html, input, key, li, link, main, obj, overlay, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
hiddenThreads = $.getValue("hiddenThreads/" + g.BOARD + "/", {});
hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length;
html = " <div class='reply dialog'> <div id=optionsbar> <div id=floaty> <a name=main>main</a> | <a name=flavors>sauce</a> | <a name=time>time</a> | <a name=keybinds>keybinds</a> </div> <div id=credits> <a href=http://chat.now.im/x/aeos>support throd</a> | <a href=https://github.com/aeosynth/4chan-x/issues>github</a> | <a href=http://userscripts.org/scripts/show/51412>uso</a> | <a href=https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2DBVZBUAM4DHC&lc=US&item_name=Aeosynth&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted>donate</a> </div> </div> <hr> <div id=content> <div id=main> </div> <textarea style='display: none;' name=flavors id=flavors>" + ($.config('flavors')) + "</textarea> <div style='display: none;' id=time> <div><input type=text name=time value='" + ($.config('time')) + "'> <span id=timePreview></span></div> <table> <caption>Format specifiers <a href=http://en.wikipedia.org/wiki/Date_%28Unix%29#Formatting>(source)</a></caption> <tbody> <tr><th>Specifier</th><th>Description</th><th>Values/Example</th></tr> <tr><td>%a</td><td>weekday, abbreviated</td><td>Sat</td></tr> <tr><td>%A</td><td>weekday, full</td><td>Saturday</td></tr> <tr><td>%b</td><td>month, abbreviated</td><td>Jun</td></tr> <tr><td>%B</td><td>month, full length</td><td>June</td></tr> <tr><td>%d</td><td>day of the month, zero padded</td><td>03</td></tr> <tr><td>%H</td><td>hour (24 hour clock) zero padded</td><td>13</td></tr> <tr><td>%I (uppercase i)</td><td>hour (12 hour clock) zero padded</td><td>02</td></tr> <tr><td>%m</td><td>month, zero padded</td><td>06</td></tr> <tr><td>%M</td><td>minutes, zero padded</td><td>54</td></tr> <tr><td>%p</td><td>upper case AM or PM</td><td>PM</td></tr> <tr><td>%P</td><td>lower case am or pm</td><td>pm</td></tr> <tr><td>%y</td><td>two digit year</td><td>00-99</td></tr> </tbody> </table> </div> <div style='display: none;' id=keybinds> <table> <tbody> <tr><th>Actions</th><th>Keybinds</th></tr> <tr><td>Close Options or QR</td><td><input type=text name=close value='Esc'></td></tr> <tr><td>Quick spoiler</td><td><input type=text name=spoiler value='ctrl+s'></td></tr> <tr><td>Jump to page 0</td><td><input type=text name=zero value='0'></td></tr> <tr><td>Open QR with post number inserted</td><td><input type=text name=openQR value='i'></td></tr> <tr><td>Open QR without post number inserted</td><td><input type=text name=openEmptyQR value='I'></td></tr> <tr><td>Select next reply</td><td><input type=text name=nextReply value='J'></td></tr> <tr><td>Select previous reply</td><td><input type=text name=previousReply value='K'></td></tr> <tr><td>See next thread</td><td><input type=text name=nextThread value='n'></td></tr> <tr><td>See previous thread</td><td><input type=text name=previousThread value='p'></td></tr> <tr><td>Open thread in current tab</td><td><input type=text name=openThread value='O'></td></tr> <tr><td>Open thread in new tab</td><td><input type=text name=openThreadTab value='o'></td></tr> <tr><td>Expand thread</td><td><input type=text name=expandThread value='e'></td></tr> <tr><td>Watch thread</td><td><input type=text name=watch value='w'></td></tr> <tr><td>Hide thread</td><td><input type=text name=hide value='x'></td></tr> <tr><td>Expand selected image</td><td><input type=text name=expandImages value='m'></td></tr> <tr><td>Expand all images</td><td><input type=text name=expandAllImages value='M'></td></tr> <tr><td>Update now</td><td><input type=text name=update value='u'></td></tr> </tbody> </table> </div> </div> </div> ";
html = " <div class='reply dialog'> <div id=optionsbar> <div id=floaty> <a name=main>main</a> | <a name=flavors>sauce</a> | <a name=time>time</a> | <a name=keybinds>keybinds</a> </div> <div id=credits> <a href=http://chat.now.im/x/aeos>support throd</a> | <a href=https://github.com/aeosynth/4chan-x/issues>github</a> | <a href=http://userscripts.org/scripts/show/51412>uso</a> | <a href=https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=2DBVZBUAM4DHC&lc=US&item_name=Aeosynth&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted>donate</a> </div> </div> <hr> <div id=content> <div id=main> </div> <textarea style='display: none;' name=flavors id=flavors>" + ($.config('flavors')) + "</textarea> <div style='display: none;' id=time> <div><input type=text name=time value='" + ($.config('time')) + "'> <span id=timePreview></span></div> <table> <caption>Format specifiers <a href=http://en.wikipedia.org/wiki/Date_%28Unix%29#Formatting>(source)</a></caption> <tbody> <tr><th>Specifier</th><th>Description</th><th>Values/Example</th></tr> <tr><td>%a</td><td>weekday, abbreviated</td><td>Sat</td></tr> <tr><td>%A</td><td>weekday, full</td><td>Saturday</td></tr> <tr><td>%b</td><td>month, abbreviated</td><td>Jun</td></tr> <tr><td>%B</td><td>month, full length</td><td>June</td></tr> <tr><td>%d</td><td>day of the month, zero padded</td><td>03</td></tr> <tr><td>%H</td><td>hour (24 hour clock) zero padded</td><td>13</td></tr> <tr><td>%I (uppercase i)</td><td>hour (12 hour clock) zero padded</td><td>02</td></tr> <tr><td>%m</td><td>month, zero padded</td><td>06</td></tr> <tr><td>%M</td><td>minutes, zero padded</td><td>54</td></tr> <tr><td>%p</td><td>upper case AM or PM</td><td>PM</td></tr> <tr><td>%P</td><td>lower case am or pm</td><td>pm</td></tr> <tr><td>%y</td><td>two digit year</td><td>00-99</td></tr> </tbody> </table> </div> <div style='display: none;' id=keybinds> <table> <tbody> <tr><th>Actions</th><th>Keybinds</th></tr> <tr><td>Close Options or QR</td><td><input type=text name=close value='Esc'></td></tr> <tr><td>Quick spoiler</td><td><input type=text name=spoiler value='ctrl+s'></td></tr> <tr><td>Jump to page 0</td><td><input type=text name=zero value='0'></td></tr> <tr><td>Open QR with post number inserted</td><td><input type=text name=openQR value='i'></td></tr> <tr><td>Open QR without post number inserted</td><td><input type=text name=openEmptyQR value='I'></td></tr> <tr><td>Select next reply</td><td><input type=text name=nextReply value='J'></td></tr> <tr><td>Select previous reply</td><td><input type=text name=previousReply value='K'></td></tr> <tr><td>See next thread</td><td><input type=text name=nextThread value='n'></td></tr> <tr><td>See previous thread</td><td><input type=text name=previousThread value='p'></td></tr> <tr><td>Jump next page</td><td><input type=text name=nextPage value='alt+x'></td></tr> <tr><td>Jump previous page</td><td><input type=text name=previousPage value='alt+z'></td></tr> <tr><td>Open thread in current tab</td><td><input type=text name=openThread value='O'></td></tr> <tr><td>Open thread in new tab</td><td><input type=text name=openThreadTab value='o'></td></tr> <tr><td>Expand thread</td><td><input type=text name=expandThread value='e'></td></tr> <tr><td>Watch thread</td><td><input type=text name=watch value='w'></td></tr> <tr><td>Hide thread</td><td><input type=text name=hide value='x'></td></tr> <tr><td>Expand selected image</td><td><input type=text name=expandImages value='m'></td></tr> <tr><td>Expand all images</td><td><input type=text name=expandAllImages value='M'></td></tr> <tr><td>Update now</td><td><input type=text name=update value='u'></td></tr> </tbody> </table> </div> </div> </div> ";
dialog = $.el('div', {
id: 'options',
innerHTML: html

View File

@ -501,6 +501,8 @@ keybinds =
keybinds.previousReply = if (key = $.getValue 'key/previousReply', 0).length then key else 'K'
keybinds.nextThread = if (key = $.getValue 'key/nextThread', 0).length then key else 'n'
keybinds.previousThread = if (key = $.getValue 'key/previousThread', 0).length then key else 'p'
keybinds.nextPage = if (key = $.getValue 'key/nextPage', 0).length then key else 'alt+x'
keybinds.previousPage = if (key = $.getValue 'key/previousPage', 0).length then key else 'alt+z'
keybinds.openThreadTab = if (key = $.getValue 'key/openThreadTab', 0).length then key else 'o'
keybinds.openThread = if (key = $.getValue 'key/openThread', 0).length then key else 'O'
keybinds.expandThread = if (key = $.getValue 'key/expandThread', 0).length then key else 'e'
@ -580,6 +582,10 @@ keybinds =
watcher.toggle thread
when keybinds.hide
threadHiding.toggle thread
when keybinds.nextPage
$('input[value=Next]')?.click()
when keybinds.previousPage
$('input[value=Previous]')?.click()
else
return
e.preventDefault()
@ -791,6 +797,8 @@ options =
<tr><td>Select previous reply</td><td><input type=text name=previousReply value='K'></td></tr>
<tr><td>See next thread</td><td><input type=text name=nextThread value='n'></td></tr>
<tr><td>See previous thread</td><td><input type=text name=previousThread value='p'></td></tr>
<tr><td>Jump next page</td><td><input type=text name=nextPage value='alt+x'></td></tr>
<tr><td>Jump previous page</td><td><input type=text name=previousPage value='alt+z'></td></tr>
<tr><td>Open thread in current tab</td><td><input type=text name=openThread value='O'></td></tr>
<tr><td>Open thread in new tab</td><td><input type=text name=openThreadTab value='o'></td></tr>
<tr><td>Expand thread</td><td><input type=text name=expandThread value='e'></td></tr>