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

Reload content scripts after install/update #1041

Closed
wants to merge 14 commits into from

Conversation

mrmr1993
Copy link
Contributor

This loads the content scripts for pages when the extension is
installed or updated (or reloaded in developer mode). This means that
the new version of Vimium will become active immediately after loading,
and so tabs won't have to be refreshed.

As a developer, this is amazing. Refreshing each tab individually after
each code change/extension reload was a pain.

@@ -0,0 +1,15 @@
injectContentScriptsIntoOpenTabs = ->
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "installActions" mean? Can this just be folded into main.coffee? This should be named install_actions to match the other scripts.

@philc
Copy link
Owner

philc commented Apr 26, 2014

This is a compelling developer workflow improvement if it works without too many side effects. Nice idea.

@philc philc added the waiting label Apr 26, 2014
@mrmr1993
Copy link
Contributor Author

@philc I think this is ready to go now, unless you have any concerns or queries.

The only minor issue I've had is that the user Link Hint CSS from the settings page is given lower precedence than content script CSS after reloading the script, which is the inverse of usual. I've tried everything that immediately occurred to me to fix it and have had no success, so I think I'm just going to leave it.

@mrmr1993
Copy link
Contributor Author

@philc I updated this PR in line with your comments. Do you have any more thoughts on this?

@deiga
Copy link
Contributor

deiga commented Aug 22, 2014

@mrmr1993 Couldn't you sort the CSS array before loading them all? Last loaded CSS should have highest precedence

@mrmr1993
Copy link
Contributor Author

@deiga the CSS arrays work perfectly, they load the scripts in exactly the same order as the brower loads them normally.

The main issue is that userDefinedLinkHintCss doesn't seem to get injected from background_scrips/mian.coffee when this happens. I'll try fiddling with it again, see what I can do.

@mrmr1993
Copy link
Contributor Author

The CSS issue is fixed now.

This loads the content scripts for pages when the extension is
installed or updated (or reloaded in developer mode). This means that
the new version of Vimium will become active immediately after loading,
and so tabs won't have to be refreshed.

As a devloper, this is amazing. Refreshing each tab individually after
each code change was a pain.
This makes vimium respond on a tab even if 1) the hack for loading
content scripts after an update is used on it and 2) the frame with
focused on that tab is not the top frame.
This reverts commit 81ba689.
chrome.tabs.executeScript provide a mechanism to avoid needing this.
@gdh1995
Copy link
Contributor

gdh1995 commented Mar 1, 2015

In fact, if the frontend ports disconnect, there are two cases:

  • a developer view the background page from chrome://extensions/, and press F5 to refresh
  • a common user click reload / "turn off & turn on" in chrome://extensions/

These commits deal with the second case well (applause).

However, for the first case, we just need to re-connect those ports, which has been proved OKay by my customized version for months. A better way, isn't it?

@gdh1995
Copy link
Contributor

gdh1995 commented Mar 1, 2015

When a port disconnects, we can try chrome.runtime.connect() and catch its exception:
connect() succeeds if only the background page is refreshed,
and throws an exception "try to connect extension null ..." if the extension has been reloaded.

By the way, what's tabUpdated in main.coffee? It appears in mrmr1993@baab020, but I can not find it in the branch mrmr1993:loadScriptsOnUpdate.

smblott-github added a commit to smblott-github/vimium that referenced this pull request Mar 7, 2015
This is @mrmr1993's work from philc#1041.

Reload content scripts when vimium is installed or updates.

(@mrmr1993:  The automatic merge was really messy (or, at least, I
couldn't figure out what was going on).  Since the bulk of philc#1041 was
actually quite compact, I took the liberty of just copying it in.  Hope
you don't mind.)
@smblott-github
Copy link
Collaborator

Closing in favour of #1521 (which is still @mrmr1993's work).

smblott-github added a commit to smblott-github/vimium that referenced this pull request Mar 7, 2015
This is @mrmr1993's work from philc#1041.

Reload content scripts when vimium is installed or updates.

(@mrmr1993:  The automatic merge was really messy (or, at least, I
couldn't figure out what was going on).  Since the bulk of philc#1041 was
actually quite compact, I took the liberty of just copying it in.  Hope
you don't mind.)
@mrmr1993 mrmr1993 deleted the loadScriptsOnUpdate branch November 12, 2017 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants