jerone / UserScripts

🐵 My UserScripts
https://github.com/jerone/UserScripts#readme
GNU General Public License v3.0
339 stars 39 forks source link

(GitHub News Feed Filter) The script sometimes doesn't work when navigating from other GitHub pages to the news feed #137

Closed darkred closed 6 years ago

darkred commented 6 years ago

Using Chrome 69 in win10, TM 4.8.5850 beta, and only GitHub News Feed Filter 8.2.4.

The issue is that some times when navigating to https://github.com/ from other GitHub pages the script doesn't work: in such cases I have to press Ctrl+F5 in order to work (plain F5 doesn't help).

STR

FWIW I've tried adding // @include https://github.com/* but unfortunately it didn't help.

jerone commented 6 years ago

Hi @darkred. Currently I'm beta testing the new personal dashboard on the homepage. This will replace the current news feed on the homepage. That's why I'm not using this userscript anymore and probably won't make any updates to the userscript until GitHub releases the new dashboard or disables the beta.

I have not checked the source yet, but this userscript might still be relevant on the new dashboard.

PR is always welcome!

darkred commented 6 years ago

Hi @jerone.

Yes, I'm also using the new dashboard layout, too. And yes, the script still works fine on the new dashboard: screenshot. It's just this issue that I describe occurs.

FYI, apart from adding

// @include       https://github.com/*

I've also tried enclosing your code as follows, like I've done with the GitHub script I have, but unfortunately it didn't help:

(function () {
    function init() {

    // ...

    }
    init();
    document.addEventListener('pjax:end', init); // for the History API
})();

Kindly /cc @Mottie in case he'd like to help here - I think that his great, detailed HowTo (especially his mutations.js library) would be the perfect solution to this. (Unfortunately it seems too advanced for me).

jerone commented 6 years ago

Yes, I'm also using the new dashboard layout, too.

Hmmm, that's weird, are you sure? Because I couldn't even get the filter to show up on the new dashboard.

To make the filter show up, change the following line...

sidebar.insertBefore(wrapper, sidebar.firstChild);

...to...

sidebar.insertBefore(wrapper, sidebar.querySelector(":scope > *:not(details)"));

It appears that all features still work.

I also can't reproduce the issue you are describing, with above steps. 😞

darkred commented 6 years ago

Hmmm, that's weird, are you sure? Because I couldn't even get the filter to show up on the new dashboard.

Yes, I'm sure: the previous screenshot I gave you is from Chrome 69 with only TM 4.7 stable(and uBO) and the script. And here is another screenshot, from a fresh Firefox 62 profile with only TM 4.8.5850 beta and the script: screenshot_2. Notice in both screenshots, the "You are in the public Beta of the dashboard" text to the bottom left, and that the filters show up ok. Also please note that in both cases the script is as it (8.2.4), i.e. without your suggested modification to line 498.


I also can't reproduce the issue you are describing, with above steps. 😞

The issue that I describe is occurring frequently but not every single time, i.e. not consistently.

Here is a video capture (1:16, ~5 MB, .wmv) with Chrome 69 and TM 4.7 stable (the same thing happens with Firefox and TM beta) : Video_2018-09-26_001858.zip [1] : I start with https://github.com/ and click in terms the links: "Pull Requests", "Issues", "Marketplace", "Explore" and (my avatar) > 'Your Profile'", and every time I switch back to https://github.com/ : the issue I describe occurs at: 0:27, 1:05 and 1:10 of the video, i.e. 3 times in total.

[1] Please download and unzip it - unfortunately uploading .wmv files is not supported by GitHub. Sorry for the inconvenience.

darkred commented 6 years ago

(I've made some corrections to my last comment to improve the wording).

jerone commented 6 years ago

When I have time I'll have a look.

One thing I did notice between you and me is the difference on the left sidebar; I've got an account switcher, which you doesn't seem to have... image (I have Refined GitHub 18.9.19.1710 disabled at the moment I made the screenshot).

darkred commented 6 years ago

When I have time I'll have a look.

Thank you! 🙂

One thing I did notice between you and me is the difference on the left sidebar; I've got an account switcher, which you doesn't seem to have...

Yes, that's very strange. I also use Refined GitHub (as well as Octotree, OctoLinker, Octobox and various styles in Stylus) but I have all these extensions disabled during the above tests, and I don't have such an account switch in any case, with any browser (Chrome, FF, even Edge).

jerone commented 6 years ago

It's because I'm part of a few organizations: https://github.com/jerone

Not related to your real issue, but if you make the code change I described above, does the news-feed-filter still show-up for you?

darkred commented 6 years ago

Yes, unfortunately it still shows up.

jerone commented 6 years ago

Yes, unfortunately it still shows up.

No no, that's good news 😄 that means that this change will make the news-feed-filter show on accounts with and without organizations.

Now I only need to reproduce your issue... 😞

darkred commented 6 years ago

No no, that's good news 😄

Yes, sorry, I misread it as "Does the issue still occur?" 😄 My answer to your question is: yes, the news-feed-filter shows on accounts with and without organizations.

jerone commented 6 years ago

Ah ok :)

I'm at work right now, and above change doesn't appear to be enough. I need to change the following to make it work:

        // GitHub homepage or profile activity tab.
-       var sidebar = document.querySelector('.dashboard-sidebar') || document.querySelector('.profilecols > .column:first-child');
+       var sidebar = document.querySelector('.dashboard-sidebar:not(.is-placeholder)') || document.querySelector('.profilecols > .column:first-child');

        var wrapper = document.createElement(filterElement);
        wrapper.classList.add('boxed-group', 'flush', 'user-repos');
-       sidebar.insertBefore(wrapper, sidebar.firstChild);
+       sidebar.insertBefore(wrapper, sidebar.querySelector(":scope > *:not(details)"));

        var headerAction = document.createElement('div');

I'll confirm that it works at home also, can you confirm if the news-feed-filter still is shown for you too...

darkred commented 6 years ago

I'll confirm that it works at home also, can you confirm if the news-feed-filter still is shown for you too...

Yes the news-feed-filter is still shown for me. And also, with these two line changes combined, the issue no longer occurs: I've tried multiple (a lot) times and I can't recreate it anymore 👍 Thanks a lot!

darkred commented 6 years ago

Something that caught my attention: I noticed in your screenshot that there's a blue counter badge (1) over the unread notifications icon: 46065031-510be780-c171-11e8-85b9-4d08e3321c57

What extension/userscript do you use for that feature?

jerone commented 6 years ago

Yes the news-feed-filter is still shown for me.

Great. 😄

And also, with these two line changes combined, the issue no longer occurs: I've tried multiple (a lot) times and I can't recreate it anymore 👍

Even greater. 😆

What extension/userscript do you use for that feature?

I used some UserScript before, but then I found the more frequently updated WebExtension, Notifications Preview for GitHub Build Status.

I'll release a new version of the the script soon.

jerone commented 6 years ago

Finally had some time to push the fix. I hope everything continues to work. 😄

darkred commented 6 years ago

Yes, everything is fine, thank you 👍