Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'RES/master'

  • Loading branch information...
commit c51a37a2e957a1dc6c4aeca266b78ae752499295 2 parents ee2b9bf + fa21dec
honestbleeps honestbleeps authored

Showing 1 changed file with 49 additions and 70 deletions. Show diff stats Hide diff stats

  1. +49 70 lib/reddit_enhancement_suite.user.js
119 lib/reddit_enhancement_suite.user.js
@@ -4490,7 +4490,8 @@ modules['keyboardNav'] = {
4490 4490 document.body.appendChild(thisHelp);
4491 4491 },
4492 4492 handleKeyPress: function(e) {
4493   - if ((document.activeElement.tagName == 'BODY') && (!(konami.almostThere))) {
  4493 + var konamitest = (typeof(konami) == 'undefined') || (!konami.almostThere)
  4494 + if ((document.activeElement.tagName == 'BODY') && (konamitest)) {
4494 4495 // comments page, or link list?
4495 4496 var keyArray = [e.keyCode, e.altKey, e.ctrlKey, e.shiftKey, e.metaKey];
4496 4497 switch(this.pageType) {
@@ -6032,7 +6033,7 @@ modules['userTagger'] = {
6032 6033 var thisXY=RESUtils.getXYpos(obj);
6033 6034 var thisUserName = obj.textContent;
6034 6035 if (thisUserName.substr(0,3) == '/u/') thisUserName = thisUserName.substr(3);
6035   - this.authorInfoToolTipHeader.innerHTML = '<a href="/user/'+thisUserName+'">' + thisUserName + '</a>';
  6036 + this.authorInfoToolTipHeader.innerHTML = '<a href="/user/'+thisUserName+'">' + thisUserName + '</a> (<a href="/user/'+thisUserName+'/submitted/">Links</a>) (<a href="/user/'+thisUserName+'/comments/">Comments</a>)';
6036 6037 RESUtils.loggedInUserInfo(function(userInfo) {
6037 6038 var myID = 't2_'+userInfo.data.id;
6038 6039 if (isFriend) {
@@ -6845,7 +6846,7 @@ modules['betteReddit'] = {
6845 6846
6846 6847 // without the next line, the subreddit manager would make the subreddit bar three lines tall and very narrow
6847 6848 RESUtils.addCSS('#sr-header-area {left: 0; right: 0;}');
6848   - spacer.style.height = window.getComputedStyle(header, null).height;
  6849 + spacer.style.height = $('#header').outerHeight() + "px";
6849 6850
6850 6851 // insert the spacer
6851 6852 document.body.insertBefore(spacer, header.nextSibling);
@@ -7289,37 +7290,13 @@ SnuOwnd["HTML_ESCAPE"]=HTML_ESCAPE;SnuOwnd["MKDEXT_NO_INTRA_EMPHASIS"]=MKDEXT_NO
7289 7290
7290 7291 function wireupExistingCommentEditors()
7291 7292 {
7292   - // opera doesn't like xpath for some reason - changing to querySelectorAll.
7293   - /*
7294   - var editDivs = document.evaluate(
7295   - "//div[@class='usertext-edit']",
7296   - document,
7297   - null,
7298   - XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
7299   - null
7300   - );
7301   - //First one is not an edit form.
7302   - for ( var i = 0; i < editDivs.snapshotLength; i++)
7303   - {
7304   - var editDiv = editDivs.snapshotItem(i);
7305   -
7306   - var preview = addPreviewToParent( editDiv );
7307   - addMarkdownEditorToForm( editDiv, preview );
7308   -
7309   - refreshPreview( preview, preview.textArea )
7310   - }
7311   - */
7312   - var editDivs = document.body.querySelectorAll('div.usertext-edit');
7313   - //First one is not an edit form.
7314   - for ( var i = 0, len=editDivs.length; i < len; i++)
7315   - {
7316   - var editDiv = editDivs[i];
  7293 + var editDivs = $('div.usertext-edit:visible');
  7294 + $(editDivs).each(function() {
  7295 + var editDiv = this;
7317 7296
7318 7297 var preview = addPreviewToParent( editDiv );
7319 7298 addMarkdownEditorToForm( editDiv, preview );
7320   -
7321   - refreshPreview( preview, preview.textArea );
7322   - }
  7299 + });
7323 7300
7324 7301 }
7325 7302
@@ -8320,7 +8297,8 @@ modules['showImages'] = {
8320 8297 RESUtils.addCSS('.RESGalleryControls .previous:hover { background-position: 0px -320px; }');
8321 8298 RESUtils.addCSS('.RESGalleryControls .next:hover { background-position: 16px -320px; }');
8322 8299 RESUtils.addCSS('.RESGalleryControls .end:hover { background-position-y: -304px; }');
8323   - RESUtils.addCSS('.imgCredits { margin-top: 6px; font-size: 11px; padding: 2px; }')
  8300 + RESUtils.addCSS('.imgTitle { font-size: 13px; padding: 2px; }')
  8301 + RESUtils.addCSS('.imgCredits { font-size: 11px; padding: 2px; }')
8324 8302 if (!this.options.displayImageCaptions.value) {
8325 8303 RESUtils.addCSS('.imgTitle, .imgCaptions { display: none; }');
8326 8304 }
@@ -8736,6 +8714,13 @@ modules['showImages'] = {
8736 8714 imageAnchor.innerHTML = '<img title="drag to resize" class="RESImage" style="max-width:'+this.options.maxWidth.value+'px;max-height:'+this.options.maxHeight.value+'px;" src="' + thisSrc + '" />';
8737 8715 var image = imageAnchor.querySelector('IMG');
8738 8716
  8717 + if ('credits' in imageLink) {
  8718 + var credits = document.createElement('div');
  8719 + credits.className = 'imgCredits';
  8720 + credits.innerHTML = imageLink.credits;
  8721 + imgDiv.appendChild(credits);
  8722 + }
  8723 +
8739 8724 imgDiv.appendChild(imageAnchor);
8740 8725
8741 8726 if ('caption' in imageLink) {
@@ -8745,12 +8730,6 @@ modules['showImages'] = {
8745 8730 imgDiv.appendChild(captions);
8746 8731 }
8747 8732
8748   - if ('credits' in imageLink) {
8749   - var credits = document.createElement('div');
8750   - credits.className = 'imgCredits';
8751   - credits.innerHTML = imageLink.credits;
8752   - imgDiv.appendChild(credits);
8753   - }
8754 8733
8755 8734 if (hasClass(expandoButton, 'commentImg')) {
8756 8735 insertAfter(expandoButton, imgDiv);
@@ -8911,7 +8890,7 @@ modules['showImages'] = {
8911 8890 url: url
8912 8891 }
8913 8892 self.postMessage(thisJSON);
8914   -
  8893 + modules['showImages'].imageTrackShift();
8915 8894 } else if (typeof(modules['showImages'].imageTrackFrame.contentWindow) != 'undefined') {
8916 8895 modules['showImages'].imageTrackFrame.contentWindow.location.replace(url);
8917 8896 } else {
@@ -9363,7 +9342,7 @@ modules['showImages'] = {
9363 9342 elem.href = info.thumbnail_url;
9364 9343 }
9365 9344 $(elem).closest('.thing').find('.thumbnail').attr('href',elem.href);
9366   - elem.credits = '<a href="'+original_url+'">[original link]</a> - Art by: <a href="'+info.author_url+'">'+info.author_name+'</a> @ DeviantArt';
  9345 + elem.credits = 'Original link: <a href="'+original_url+'">'+original_url+'</a><br>Art by: <a href="'+info.author_url+'">'+info.author_name+'</a> @ DeviantArt';
9367 9346 elem.type = 'IMAGE';
9368 9347 modules['showImages'].createImageExpando(elem);
9369 9348 }
@@ -9425,7 +9404,7 @@ modules['showImages'] = {
9425 9404 break;
9426 9405 }
9427 9406 $(elem).closest('.thing').find('.thumbnail').attr('href',elem.href);
9428   - elem.credits = '<a href="'+original_url+'">[original post]</a> by: <a href="'+info.response.blog.url+'">'+info.response.blog.name+'</a> @ Tumblr';
  9407 + elem.credits = 'Original post: <a href="'+original_url+'">'+original_url+'</a><br>By: <a href="'+info.response.blog.url+'">'+info.response.blog.name+'</a> @ Tumblr';
9429 9408 modules['showImages'].createImageExpando(elem);
9430 9409 }
9431 9410 },
@@ -9509,13 +9488,13 @@ modules['showKarma'] = {
9509 9488 var karmaDiv = document.querySelector("#header-bottom-right .userkarma");
9510 9489 if ((typeof(karmaDiv) != 'undefined') && (karmaDiv != null)) {
9511 9490 var linkKarma = karmaDiv.innerHTML;
9512   - karmaDiv.title = 'link / comment karma';
  9491 + karmaDiv.title = '';
9513 9492 var commentKarma = userInfo.data.comment_karma;
9514 9493 if (modules['showKarma'].options.useCommas.value) {
9515 9494 linkKarma = RESUtils.addCommas(linkKarma);
9516 9495 commentKarma = RESUtils.addCommas(commentKarma);
9517 9496 }
9518   - karmaDiv.innerHTML = linkKarma + " " + modules['showKarma'].options.separator.value + " " + commentKarma;
  9497 + karmaDiv.innerHTML = "<a title=\"link karma\" href=\"/user/" + RESUtils.loggedInUser() + "/submitted/\">" + linkKarma + "</a> " + modules['showKarma'].options.separator.value + " <a title=\"comment karma\" href=\"/user/" + RESUtils.loggedInUser() + "/comments/\">" + commentKarma + "</a>";
9519 9498 }
9520 9499 }
9521 9500 };
@@ -9860,6 +9839,18 @@ modules['neverEndingReddit'] = {
9860 9839 delete sessionStorage['NERpage'];
9861 9840 */
9862 9841 if (this.options.returnToPrevPage.value) {
  9842 + // if the user clicks any external links, save that link
  9843 + // Creating custom :external selector
  9844 + $.expr[':'].external = function(obj){
  9845 + return !obj.href.match(/^mailto\:/)
  9846 + && (obj.hostname != location.hostname);
  9847 + };
  9848 +
  9849 + // Add 'external' CSS class to all external links
  9850 + $("a:external").click(function(e) {
  9851 + // if left click and not going to open in a new tab...
  9852 + if ((this.target != '_blank') && (e.which == 1)) sessionStorage.lastPageURL = this.href;
  9853 + });
9863 9854 this.returnToPrevPageCheck();
9864 9855 }
9865 9856
@@ -9867,8 +9858,6 @@ modules['neverEndingReddit'] = {
9867 9858 if (this.options.autoLoad.value) {
9868 9859 window.addEventListener('scroll', modules['neverEndingReddit'].handleScroll, false);
9869 9860 }
9870   - } else {
9871   - sessionStorage.lastPageURL = location.href;
9872 9861 }
9873 9862 // hide any next/prev page indicators
9874 9863 var nextprev = document.body.querySelectorAll('.content p.nextprev');
@@ -9931,6 +9920,9 @@ modules['neverEndingReddit'] = {
9931 9920 this.attachModalWidget();
9932 9921 // Set the current page to page 1...
9933 9922 this.currPage = 1;
  9923 + // console.log(sessionStorage.NERpageURL);
  9924 + // console.log(sessionStorage.lastPageURL);
  9925 + // console.log(sessionStorage.NERpage);
9934 9926 if ((sessionStorage.NERpageURL) && (sessionStorage.NERpageURL != sessionStorage.lastPageURL)) {
9935 9927 var backButtonPageNumber = sessionStorage.getItem('NERpage') || 1;
9936 9928 if (backButtonPageNumber > 1) {
@@ -11933,30 +11925,16 @@ modules['newCommentCount'] = {
11933 11925 if ((this.isEnabled()) && (this.isMatchURL())) {
11934 11926 // go!
11935 11927 var counts = RESStorage.getItem('RESmodules.newCommentCount.counts');
11936   - if (counts == null) {
11937   - counts = '{}';
11938   - }
  11928 + if (counts == null) counts = '{}';
11939 11929 this.commentCounts = safeJSON.parse(counts, 'RESmodules.newCommentCount.counts');
11940 11930 if (RESUtils.pageType() == 'comments') {
11941 11931 this.updateCommentCount();
11942 11932 document.body.addEventListener('DOMNodeInserted', function(event) {
11943 11933 if ((event.target.tagName == 'DIV') && (hasClass(event.target,'thing'))) {
11944   - modules['newCommentCount'].updateCommentCount();
  11934 + modules['newCommentCount'].updateCommentCount(true);
11945 11935 }
11946 11936 }, true);
11947 11937 this.addSubscribeLink();
11948   - // this just doesn't really work that well since often times new comments are under the "load more comments" threshhold
11949   - // or if you are visiting the thread often, Reddit Gold doesn't even mark the comments new...
11950   - /*
11951   - if (typeof(this.commentCounts[this.currentCommentID].subscriptionDate) != 'undefined') {
11952   - // we are subscribed to this thread already, so scroll to first new post if possible...
11953   - var firstNew = document.querySelector('.new-comment');
11954   - if (firstNew) {
11955   - thisXY=RESUtils.getXYpos(firstNew);
11956   - RESUtils.scrollTo(0,firstNew);
11957   - }
11958   - }
11959   - */
11960 11938 } else if (RESUtils.currentSubreddit('dashboard')) {
11961 11939 // If we're on the dashboard, add a tab to it...
11962 11940 // add tab to dashboard
@@ -12007,8 +11985,10 @@ modules['newCommentCount'] = {
12007 11985 this.commentCounts[i].id = i;
12008 11986 // grab the subreddit out of the URL and store it in match[i]
12009 11987 var match = this.commentCounts[i].url.match(RESUtils.matchRE);
12010   - this.commentCounts[i].subreddit = match[1].toLowerCase();
12011   - thisCounts.push(this.commentCounts[i]);
  11988 + if (match) {
  11989 + this.commentCounts[i].subreddit = match[1].toLowerCase();
  11990 + thisCounts.push(this.commentCounts[i]);
  11991 + }
12012 11992 }
12013 11993 $('#newCommentsTable tbody').html('');
12014 11994 switch (this.currentSortMethod) {
@@ -12137,7 +12117,7 @@ modules['newCommentCount'] = {
12137 12117 }
12138 12118 }
12139 12119 },
12140   - updateCommentCount: function() {
  12120 + updateCommentCount: function(mycomment) {
12141 12121 var IDre = /\/r\/[\w]+\/comments\/([\w]+)\//i;
12142 12122 var matches = IDre.exec(location.href);
12143 12123 if (matches) {
@@ -12153,6 +12133,7 @@ modules['newCommentCount'] = {
12153 12133 if (diff>0) thisCount.innerHTML = this.currentCommentCount + ' comments ('+diff+' new)';
12154 12134 }
12155 12135 if (isNaN(this.currentCommentCount)) this.currentCommentCount = 0;
  12136 + if (mycomment) this.currentCommentCount++;
12156 12137 }
12157 12138 } else {
12158 12139 this.currentCommentCount++;
@@ -14854,9 +14835,7 @@ modules['dashboard'] = {
14854 14835 this.getLatestWidgets();
14855 14836 var exists = false;
14856 14837 for (var i=0, len=modules['dashboard'].widgets.length; i<len; i++) {
14857   - console.log(modules['dashboard'].widgets[i].basePath + ' == ' + optionsObject.basePath);
14858 14838 if (modules['dashboard'].widgets[i].basePath == optionsObject.basePath) {
14859   - console.log('exists!');
14860 14839 exists = true;
14861 14840 $('#'+modules['dashboard'].widgets[i].basePath.replace(/\/|\+/g,'_')).fadeOut('slow', function(ele) {
14862 14841 $(this).detach();
@@ -17728,11 +17707,11 @@ guiders = (function($){
17728 17707 // go through each module and run it
17729 17708 for (var thisModuleID in modules) {
17730 17709 if (typeof(modules[thisModuleID]) == 'object') {
17731   - //console.log(thisModuleID + ' start: ' + Date());
17732   - //perfTest(thisModuleID+' start');
  17710 + // console.log(thisModuleID + ' start: ' + Date());
  17711 + // perfTest(thisModuleID+' start');
17733 17712 modules[thisModuleID].go();
17734   - //perfTest(thisModuleID+' end');
17735   - //console.log(thisModuleID + ' end: ' + Date());
  17713 + // perfTest(thisModuleID+' end');
  17714 + // console.log(thisModuleID + ' end: ' + Date());
17736 17715 }
17737 17716 }
17738 17717 GM_addStyle(RESUtils.css);

0 comments on commit c51a37a

Please sign in to comment.
Something went wrong with that request. Please try again.