willklein / markdown-menu

Browser extension that adds a navigation menu to any readme or Markdown file on GitHub.com
https://chrome.google.com/webstore/detail/markdown-menu-for-github/jekgocfoijmbgcjejohdgmojaejofdpo
MIT License
41 stars 18 forks source link

Make compatible with refined-github #12

Open willklein opened 8 years ago

willklein commented 8 years ago

On repo homeages for README files, Refined GitHub removes the header where the button is inserted. Place the button in the same container as their edit button.

willklein commented 8 years ago

This might be blocked, I don't see a way to know when the other extension has finished, and we can't just setTimeout due to a content security policy.

DrewML commented 8 years ago

@willklein Thanks for working on this - love the extension!

we can't just setTimeout due to a content security policy.

One of the Refined-GitHub PRs had this issue. You could try switching from setTimeout to a setInterval that clears itself in the callback.

If that's not ideal though, I'm sure we can find another way.

sindresorhus commented 8 years ago

Maybe refined-github could emit a global event when it's done?

willklein commented 8 years ago

@sindresorhus: Nice idea, I was thinking about that too. There might still be a race condition though. What if github-markdown-menu renders first, and then refined-github wipes out the header we modified?

Another approach is agreeing on a DOM container that, if present, we both update. Whoever renders first inserts the container, and whoever renders later updates it.

I think @DrewML's suggestion will probably work, I just didn't get a chance to try it yet. If so, that should delay rendering of github-markdown-menu so it always renders second, and then there are no changes needed in refined-github. I'll try that soon.

willklein commented 8 years ago

Oh, on second thought, @sindresorhus's idea to emit a global event could also work without a race condition. github-markdown-menu may render first, but if refined-github also renders, emits an event, then I just re-render github-markdown-menu. I still want to try the setInterval next.

Seems like these ideas are all "hacks," but that's what browser extensions are for. :smile: