Skip to content

Commit

Permalink
fixed a few issues:
Browse files Browse the repository at this point in the history
- option to not focus links with shift-enter on keynav
- support for hashed links in comments to stay on same page rather than open new tab
- odd vote behavior when voting on deleted posts
  • Loading branch information
honestbleeps committed Apr 14, 2012
1 parent 82dcafc commit 45eed3d
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions lib/reddit_enhancement_suite.user.js
Expand Up @@ -4572,6 +4572,11 @@ modules['keyboardNav'] = {
value: [13,false,false,true], // shift-enter
description: 'Follow link in new tab (link pages only)'
},
followLinkNewTabFocus: {
type: 'boolean',
value: true,
description: 'When following a link in new tab - focus the tab?'
},
toggleExpando: {
type: 'keycode',
value: [88,false,false,false], // x
Expand Down Expand Up @@ -5280,11 +5285,12 @@ modules['keyboardNav'] = {
if ((modules['keyboardNav'].options.commentsLinkNewTab.value) || e.ctrlKey) {
button = 1;
}
if (button == 1) {
var thisURL = this.getAttribute('href');
if ((thisURL.indexOf('#') == -1) && (button == 1)) {
if (typeof(chrome) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: this.getAttribute('href'),
linkURL: thisURL,
button: button
}
chrome.extension.sendRequest(thisJSON, function(response) {
Expand All @@ -5294,21 +5300,21 @@ modules['keyboardNav'] = {
} else if (typeof(safari) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: this.getAttribute('href'),
linkURL: thisURL,
button: button
}
safari.self.tab.dispatchMessage("keyboardNav", thisJSON);
} else if (typeof(opera) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: this.getAttribute('href'),
linkURL: thisURL,
button: button
}
opera.extension.postMessage(JSON.stringify(thisJSON));
} else if (typeof(self.on) == 'function') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: this.getAttribute('href'),
linkURL: thisURL,
button: button
}
self.postMessage(thisJSON);
Expand Down Expand Up @@ -5860,10 +5866,13 @@ modules['keyboardNav'] = {
var thisHREF = thisA.getAttribute('href');
// console.log(thisA);
if (newWindow) {
var button = (this.options.followLinkNewTabFocus.value) ? 0 : 1;
console.log(button);
if (typeof(chrome) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: thisHREF
linkURL: thisHREF,
button: button
}
chrome.extension.sendRequest(thisJSON, function(response) {
// send message to background.html to open new tabs...
Expand All @@ -5872,19 +5881,22 @@ modules['keyboardNav'] = {
} else if (typeof(safari) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: thisHREF
linkURL: thisHREF,
button: button
}
safari.self.tab.dispatchMessage("keyboardNav", thisJSON);
} else if (typeof(opera) != 'undefined') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: thisHREF
linkURL: thisHREF,
button: button
}
opera.extension.postMessage(JSON.stringify(thisJSON));
} else if (typeof(self.on) == 'function') {
thisJSON = {
requestType: 'keyboardNav',
linkURL: thisHREF
linkURL: thisHREF,
button: button
}
self.postMessage(thisJSON);
} else {
Expand Down Expand Up @@ -6326,8 +6338,8 @@ modules['userTagger'] = {
var pairNum = e.target.getAttribute('pairNum');
if (pairNum) pairNum = parseInt(pairNum);
var thisAuthorA = this.parentNode.nextSibling.querySelector('p.tagline a.author');
// ???? TODO: fix on posts with thumbnails?
if (thisAuthorA == null && this.parentNode.nextSibling.nextSibling != null) {
// if this is a post with a thumbnail, we need to adjust the query a bit...
if (thisAuthorA == null && hasClass(this.parentNode.nextSibling,'thumbnail')) {
thisAuthorA = this.parentNode.nextSibling.nextSibling.querySelector('p.tagline a.author');
}
if (thisAuthorA) {
Expand Down

0 comments on commit 45eed3d

Please sign in to comment.