-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Major improvements in code extensibility, reduced API usage, eliminate redundancy, etc. #348
Conversation
@GaurangTandon Wow, thanks a lot for your time! I will go through this as soon as I can, but I'm sure it'll be fine! I'll also have a look at the points you mentioned and try fixing them too :) I was thinking of moving downvotedPostsEditAlert back out into a separate userscript too, because it's too big to maintain in SOX! |
@@ -81,22 +81,19 @@ | |||
|
|||
copyCommentsLink: function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were changes to this function by accident? (It seems to have rolled back my changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably. I do recall starting work on the latest dev branch. Ah...you went from dev*.*.14
to dev*.*.15
by the time I finished work, Hadn't noticed that. Sorry! Feel free to roll back to your original.
|
||
//display:block to fix https://github.com/soscripted/sox/issues/243: | ||
$('#question-header').css('display', 'block').prepend('<div title="SOX: this is a hot network question!" ' + (sox.location.on('english.stackexchange.com') ? 'style="padding:13px"' : '') + ' class="sox-hot"><i class="fab fa-free-code-camp"></i><div>'); | ||
$(document.getElementById('question-header')).css('display', 'block').prepend('<div title="SOX: this is a hot network question!" ' + (sox.location.on('english.stackexchange.com') ? 'style="padding:13px"' : '') + ' class="sox-hot"><i class="fab fa-free-code-camp"></i><div>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point in using vanilla JS just to make it a jQuery object straight after? :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, $(document.getElementById(ID))
is quite faster than $("#ID")
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@GaurangTandon fair enough, I never knew that!
@GaurangTandon merged! thanks again for all the changes -- it must have taken quite some time! :) |
That's wonderful :D |
@GaurangTandon I've fixed most of the issues you mentioned, but I couldn't reproduce the duplicate button's link being broken -- does it still happen? I have no idea why I used YQL for the migrated questions 😆 I also had something in there to check for 'migrated from' but AFAIK the migrated notice only shows on the 'from' site? For multiple duplicates, it just shows one of them... I'll be taking out downvotedPostsEditAlert soon. |
If I go to this search page, and click the first duplicate link, it immediately transforms from I've little clue as to why this happens. If it possible that you have a rogue click event handler (probably a delegated one) somewhere in the code? :O I'm testing on a fresh Chrome profile specifically for testing SOX only, so effect of other addons is zero. |
@GaurangTandon very weird :/ it only happens on the search page, not on any other page e.g. https://stackoverflow.com/questions. I'll look at features that act on the search page... |
Fixed it! If you're interested, it was:
on line 1332 of the /search page: I honestly have no clue why it's there :/ I tried changing it to:
but that click handler never got triggered, no idea why. So, in the end, I just added a |
Woah, how did you manage to find that line of code in the middle of nowhere o.O 10/10 great!
Oh, I get it! This code must be for their internal analytics: tracking the referrer. The original
I guess this is because
That is the perfect trick my friend ;) applauses |
This is really minor so I'll comment it here. |
I'm away for a few days but I'll look at that when I get back :)
I still don't get why the click handler itself never ran :/ (I added a `console.log('test');` to the `click` but it just refused to detect it!
Thanks 😆
|
@GaurangTandon I'm looking at it now -- do you mean this box shouldn't be clickable? |
Aye, this box itself, and also the |
@GaurangTandon should be fixed in dev 2.2.22 :) |
Dude....that's probably an overkill :( Those Look, the thing is that this |
Fair enough, although I feel we need some visual indicator that you can hover over them, and add this to the feature's |
You will hover over the links to click them anyway. Once you hover over them, the tags list immediately pops out below the question link. Try it out! ;) |
The idea is to see the question tags before you click. If you don't know to hover to show the tags, there's no reason you should hover (by clicking) at all because you just wouldn't go to the question. |
So, you're saying that once this update goes alive, any user - interested in this feature - won't hover over any HNQ question, even once, even by mistake, before thinking that That's a bit of an overstatement in my humble opinion, considering that there is almost a negligible delay in the fetching of the tags, I have pushed another update to #351, that should make the app's response time zero. Please have a look. |
I'm saying it's not an obvious feature, and there's no need for a user to accidentally realise they can show the tags by hovering when we can just add a line of text that makes it obvious! |
Well, alright with that. |
* new dev * #305 * #307 * #310 * #310 * Better fix for #310 The old fix placed the SOX button to the right of the username, but the username only shows up in the top bar if you're logged in. This meant the SOX button would be absent if you were logged out. This new code should fix that. * #310 * #309, #313 * #311, #312 * #256 * #319, #317, #316 * #256 * #318 * #294 deprecate enhanced editor * #308, other small fixes * #320 * minor fixes (#324) change scroll top top feature JSON info * fixes #329 (#330) also reduces jQuery dependency * v2.1.4 DEV before push to master also adds #326 * v2.2.0 * inital DEV push * update readme to state GM not supported; #306 * reduce dependency on `hotkeys`+minor details (#333) * #334 fixed * #334 * #334 * #338 * #335, #338 * Micro optimizations (#336) * update source link * micro optimizations - converted jQuery .not to CSS selector for faster perf (https://stackoverflow.com/questions/8845811/performance-differences-between-using-not-and-not-selectors) - introduced a separate function to eliminate thrice-repeated (!) code, to keep it DRY * fixes some issues (#339) described in #338 (comment) * fixes #338 * fixes #338 (#340) 1. used addEventListener instead of onload 2. descriptive names (`reader`) 3. optimized extraction of the image URL from the `data` 4. made all declarations `var` and moved them into one place for consistency 5. shortened the POST url to simply `'/upload/image?https=true',` ;P * #322 implemented * Sticky property * Update sox.user.js * Updating button colors The main SE buttons use a lighter color than the SOX buttons * Update sox.css * Minor fixes Patched a problem with vote buttons, and fixed the color of the notify on edit button * Update sox.user.js * minor changes/fixes * #341 temporary fix * Updated mod diamond icon Updated to the icon, to match the one used by the new topbar * Updated diamond icon * Updated mod diamond * improvements in colorAnswerer (#344) * improvements in colorAnswerer 1. constant variables+cache answeredID 2. reduce jQuery dependency+shorter a[href] selector via user ID 3. change coloration * optimization: use filters throughout (#345) reduces bandwidth consumption * fixes a few features; adds CSS Fixes moveBounty, dragBounty, copyCommentsLink. Adds class for colorAnswerer. Updates jQuery * fixes quickAuthorInfo fontawesome icon * fix a few of #308 * Major improvements in code extensibility, reduced API usage, eliminate redundancy, etc. (#348) * fixes various bugs mentioned in #348 * fixes standOutDupeCloseMigrated for search pages * remove unwanted console logs * #347, various minor tweaks * fixes small bug in parseCrossSiteLinks e.g. on this comment: https://meta.stackoverflow.com/questions/370902/i-need-a-lot-of-help-to-write-a-query-for-the-stack-exchange-data-explorer-sh?cb=1#comment608548_370902 * Fixed Meta SE's chat link Added a / to the end of Meta SE's if statement to fix it. Also replaced "discuss" with "meta" for Area 51 (to match the new URL for Area 51 Discussions), shortened a bit of code, and added some comments * Fixed Meta SE links * Changed topbar z-index Changed the fixed topbar's z-index to match the one on SO, in order to prevent elements like the usercard (z-index: 1000) from covering it * Made it clearer what the checkbox does * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Fixed Area 51 Discussions bug * #348 minor tweak * fix (#350) ...for answerer ID 13 also matching commenter ids beginning with 13 (1345, 13555, etc.) * #352, #353 remove yahoo YQL use * #352 * PR/351 (#355) * update getQuestionTags * provide immediate response to user * minor changes * #325: remove rangyInputs dependency (#354) * bump version number * remove downvotedPostsEditAlert; remove rangyinputs `require`; implement mini changelog in dialog * install stale and no-response bots * #356 added, minor bug fix * start #349, start to move to es6 * onlyShowCommentActionsOnHover bug fix * #357 * deprecate fixedTopbar feature for #349 * add showTagWikiLinkOnTagPopup feature * #359 fixed * #358 fixed * fixes #360 * fixes for #361 * #361 changes * v2.3.0 final
I (finally!) got round to pushing this to master under 2.3.0! Thanks a lot for your help in this version @GaurangTandon! :) 🎉 |
You're welcome, I'm glad to help :)
…On Sun 2 Sep, 2018, 19:49 ᔕᖺᘎᕊ, ***@***.***> wrote:
I (finally!) got round to pushing this to master under 2.3.0! Thanks a lot
for your help in this version @GaurangTandon
<https://github.com/GaurangTandon>! :) 🎉
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#348 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AGBDSy516fAnZ0_6sVPC4mQ-TbRancymks5uW-kOgaJpZM4VI8QN>
.
|
* new dev * #305 * #307 * #310 * #310 * Better fix for #310 The old fix placed the SOX button to the right of the username, but the username only shows up in the top bar if you're logged in. This meant the SOX button would be absent if you were logged out. This new code should fix that. * #310 * #309, #313 * #311, #312 * #256 * #319, #317, #316 * #256 * #318 * #294 deprecate enhanced editor * #308, other small fixes * #320 * minor fixes (#324) change scroll top top feature JSON info * fixes #329 (#330) also reduces jQuery dependency * v2.1.4 DEV before push to master also adds #326 * v2.2.0 * inital DEV push * update readme to state GM not supported; #306 * reduce dependency on `hotkeys`+minor details (#333) * #334 fixed * #334 * #334 * #338 * #335, #338 * Micro optimizations (#336) * update source link * micro optimizations - converted jQuery .not to CSS selector for faster perf (https://stackoverflow.com/questions/8845811/performance-differences-between-using-not-and-not-selectors) - introduced a separate function to eliminate thrice-repeated (!) code, to keep it DRY * fixes some issues (#339) described in #338 (comment) * fixes #338 * fixes #338 (#340) 1. used addEventListener instead of onload 2. descriptive names (`reader`) 3. optimized extraction of the image URL from the `data` 4. made all declarations `var` and moved them into one place for consistency 5. shortened the POST url to simply `'/upload/image?https=true',` ;P * #322 implemented * Sticky property * Update sox.user.js * Updating button colors The main SE buttons use a lighter color than the SOX buttons * Update sox.css * Minor fixes Patched a problem with vote buttons, and fixed the color of the notify on edit button * Update sox.user.js * minor changes/fixes * #341 temporary fix * Updated mod diamond icon Updated to the icon, to match the one used by the new topbar * Updated diamond icon * Updated mod diamond * improvements in colorAnswerer (#344) * improvements in colorAnswerer 1. constant variables+cache answeredID 2. reduce jQuery dependency+shorter a[href] selector via user ID 3. change coloration * optimization: use filters throughout (#345) reduces bandwidth consumption * fixes a few features; adds CSS Fixes moveBounty, dragBounty, copyCommentsLink. Adds class for colorAnswerer. Updates jQuery * fixes quickAuthorInfo fontawesome icon * fix a few of #308 * Major improvements in code extensibility, reduced API usage, eliminate redundancy, etc. (#348) * fixes various bugs mentioned in #348 * fixes standOutDupeCloseMigrated for search pages * remove unwanted console logs * #347, various minor tweaks * fixes small bug in parseCrossSiteLinks e.g. on this comment: https://meta.stackoverflow.com/questions/370902/i-need-a-lot-of-help-to-write-a-query-for-the-stack-exchange-data-explorer-sh?cb=1#comment608548_370902 * Fixed Meta SE's chat link Added a / to the end of Meta SE's if statement to fix it. Also replaced "discuss" with "meta" for Area 51 (to match the new URL for Area 51 Discussions), shortened a bit of code, and added some comments * Fixed Meta SE links * Changed topbar z-index Changed the fixed topbar's z-index to match the one on SO, in order to prevent elements like the usercard (z-index: 1000) from covering it * Made it clearer what the checkbox does * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Many fixes to dialog buttons Fixes many of the bugs from #308 * Fixed Area 51 Discussions bug * #348 minor tweak * fix (#350) ...for answerer ID 13 also matching commenter ids beginning with 13 (1345, 13555, etc.) * #352, #353 remove yahoo YQL use * #352 * PR/351 (#355) * update getQuestionTags * provide immediate response to user * minor changes * #325: remove rangyInputs dependency (#354) * bump version number * remove downvotedPostsEditAlert; remove rangyinputs `require`; implement mini changelog in dialog * install stale and no-response bots * #356 added, minor bug fix * start #349, start to move to es6 * onlyShowCommentActionsOnHover bug fix * #357 * deprecate fixedTopbar feature for #349 * add showTagWikiLinkOnTagPopup feature * #359 fixed * #358 fixed * fixes #360 * fixes for #361 * #361 changes * v2.3.0 final * 2.3.0 DEV * fix for #363 * implemented 'feature packs' in settings dialog * debugging for #363, fixes #364 * #363 debugging * fix for #363 * #361 implemented (access token no longer mandatory); minor code cleanup * #365 * fix #368 * Add #315 * fix #366 * start to use linting * fix #372 * add #370 * clean up code * implement #374 * fix #373 * add #370; deprecate pasteImagesDirectly * #374 replace 'help' instead of prepend new link * change indentation to 2 spaces * lint * implement #296 * implements #376 (linkify meta diamond dialog title) * fix #375 (topAnswers post score not being found) * improve customMagicLinks feature -- add button to help menu on all pages * fix sticky vote buttons feature * keep new meta posts under diamond even after clicking (#378) * editComment improve design, add more defaults (#377) * fix better css feature * editComment: make dialog delete button smaller * improve editComment for #377; allow editing; new setting storage format * add delay to comment features for links to deleted comments #379 * bump to v2.4.0 * Remove accidental letter introduced into file * Bump installation link version numbers * Lint
My main motive in this four days attempt was to first reduce the heavy API usage by introducing filters. As I got engrossed in the code further, I managed to fix issues related to code extensibility, redudancy, refactoring, caching, etc. So, this turned out to be a slightly larger update than expected.
This PR builds on the code directly from the latest branch (dev2.2.15). I have tested all the functions that I changed. They all work, except for a few quirks that were present since before.
These are the most important changes:
getFromAPI
MutationObserver
fires dozens of times a second, but the user we're designing this app for won't even notice changes faster than 250ms.apiParameter
list incommon.info.json
was redundant, since none of the files are actually using the corresponding methodsapiParameter
ormetaApiParameter
. So, I removed that.parseCrossSiteLinks
now also works for bare links in commentssox.helpers
- as they are frequently used in the codecurrentAPIParameter
using the helper method aboveApart from that, all the other changes fix bugs, or make the code extensible, faster, less redundant, etc. However, there are a few things I could not fix:
downvotedPostsEditAlert
- I don't know where to begin refactoring this from. It has three API calls, and more than four hundred lines of code. I can't even comprehend how it is doing what it's supposed to do. Perhaps, you might want to refactor it later yourself. At least reduce its length, its huge :O$anchor
inshowQuestionStateInSuggestedEditReviewQueue
? I think you forgot to define that variable.standOutDupeCloseMigrated
? The SE API already provides us withmigrated_from
andmigrated_to
details.standOutDupeCloseMigrated
? It is a known fact that moderators can mark more than one dupe targets for a single question.hotNetworkQuestionsFiltering
is unable to hide those links which are under the "more hot questions" link. As soon as you click that link, all the list items under that automatically appear. I think it needs an onclick handler for that.standOutDupeCloseMigrated
dupe stamp link is/q/ID
when it is set, but becomes/undefined
when you click on it.getQuestionTags
part ofhotNetworkQuestionsFiltering
has been buggy since previous version. there is no next element sibling ofi.getQuestionTags
Since this is a big change, feel free to go through it manually and comment and ping me for changes on individual lines - I'll be more than happy to explain my changes. Even though I have tested all the changed methods, feel free to test them again :)
And when you're happy, we can push these changes, possibly under a new
2.3.0
version number ;)