Skip to content
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

pjax listener #26

Merged
merged 4 commits into from
Mar 20, 2021
Merged

pjax listener #26

merged 4 commits into from
Mar 20, 2021

Conversation

odnar-dev
Copy link
Contributor

closes : #9

@odnar-dev odnar-dev changed the title pjax pjax listener Mar 19, 2021
@payne911
Copy link
Collaborator

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

@odnar-dev
Copy link
Contributor Author

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

yes

@payne911
Copy link
Collaborator

payne911 commented Mar 19, 2021

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.

@payne911 payne911 added chrome plugin enhancement New feature or request labels Mar 19, 2021
@odnar-dev
Copy link
Contributor Author

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

  • Pjax fetched only partes of Forks page via AJAX and rendered it without reloading the page layout or any resources (js, css ...)
  • then it updates the browser's current URL using history.pushstat

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Collaborator

Okay, you explained it really well, thank you!

@payne911 payne911 merged commit d03e562 into useful-forks:master Mar 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrome plugin enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opening Forks page from within another Insights tab does not trigger the scan
2 participants