useful-forks / useful-forks.github.io

Improving GitHub's Forks list discoverability through automatic filtering. The project offers an online tool and a Chrome extension.
https://useful-forks.github.io/
MIT License
1.18k stars 61 forks source link

pjax listener #26

Closed odnar-dev closed 3 years ago

odnar-dev commented 3 years ago

closes : https://github.com/useful-forks/useful-forks.github.io/issues/9

payne911 commented 3 years ago

Have you tested the 2 scenarios I mentioned there? https://github.com/useful-forks/useful-forks.github.io/pull/21#issuecomment-802530653

odnar-dev commented 3 years ago

Have you tested the 2 scenarios I mentioned there? #21 (comment)

yes

payne911 commented 3 years ago

The manifest.json config change from "*://github.com/*/network/members" to "*://github.com/*/*": would you mind explaining why that is necessary ? I thought keeping the matches as restrictive as possible would be the best.

I tried your changes with "*://github.com/*/network/members", for example, and the init() function still gets called when I open Dependencies and Network pages. I think there is something I don't understand about this content_script's matches value.

odnar-dev commented 3 years ago

when you go to Dependencies then click on Forks it look like the whole page changed but what actually happened is that :

i added an event listeners that monitor pjax requests then call init() after it ended.

document.addEventListener('pjax:end', init);

the init() function well check if current URL is "*://github.com/*/network/members" then add css and run initial_request()

if (pathComponents[4] == "members"){...

odnar-dev commented 3 years ago

chrome extensions normally doesnt monitor history.pushstat so when you go to Forks from Dependencies page your extension didn't get enabled cause chrome still think you are in the Dependencies page

odnar-dev commented 3 years ago

if you wanna keep the matches as restrictive as possible you need to add every page that link to Forks page and use pjax

      "matches": [
        "*://github.com/*/*/community",
        "*://github.com/*/*/graphs/*",
        "*://github.com/*/*/network/*",
        "*://github.com/*/*/pulse"
      ],
payne911 commented 3 years ago

Okay, you explained it really well, thank you!