Refined-github: Add support for GitHub Enterprise domains

Created on 18 Oct 2016  路  16Comments  路  Source: sindresorhus/refined-github

鉂囷笍
@fregante wrote: Hey Google user! If you鈥檙e looking for a way to add GitHub Enterprise support to your browser extension, check out this guide: https://github.com/fregante/webext-dynamic-content-scripts/blob/master/how-to-add-github-enterprise-support-to-web-extensions.md I added this message here because I noticed that this issue is one of the first results.
鉂囷笍

I think it's great that you've limited the extension to only accessing data on the github.com domain but this prevents me from using it with GitHub Enterprise which runs on an internal domain.

enhancement enterprise help wanted

Most helpful comment

This extension provides a simple way of managing and enabling GHE:
https://github.com/buunguyen/octotree#enterprise-urls

After adding it to the list and saving, the browser prompts whether you want to allow it on that domain.

All 16 comments

I don't use GHE, but I'm open to supporting it in the extension. However I don't know if it's easily possible without getting access to all domains. Any ideas on how this could be implemented are welcome!

@nobso has described a work-around in #318:

i could manually add an origin in the manifest.json and import it into my browser to make it work for now.

@hkdobrev Why cant we allow the user to input an additional domain (just one domain at least)?

Yep, I think building the plugin locally and setting the domain is a suitable workaround for me.

@nobso

Why can't we allow the user to input an additional domain (just one domain at least)?

The list of domains which the extension could access is a static list in the manifest and the user is prompted to approve this list upon installation. To the best of my knowledge, we don't have the ability to add domains to that list dynamically based on something the user enters in an options screen.

https://github.com/sindresorhus/refined-github/blob/27f9b391/extension/manifest.json#L8-L10

We can ask for permission to modify sites on every domain, but this is not a good practice and normal GitHub users could be disturbed to give permission to modify all websites to an extension meant to operate on GitHub only.

Yep, I think building the plugin locally and setting the domain is a suitable workaround for me.

That could be a good workaround for now.


If anyone knows if we can add such domains dynamically or if you think asking for permission on all websites in order to support GitHub enterprise is reasonable, please chime in.

@hkdobrev I think I found an extension that does something similar (after reading this issue).

I'm trying to find a way to be able to minimize my diffs on GitHub enterprise, and came across this:

It allowed me to provide a URL in its options and then Chrome asked if I'd like to give that extension permission to that page. Maybe that method would work for you too? Skimming their code very briefly it seems to use this:

Might be worth mentioning that I couldn't get the above extension to work, so either Chrome asking for permission did nothing or the extension itself has some bugs.

From Chrome extension docs you've linked:

If you want to request hosts that you only discover at runtime, include "http://\*/" and/or "https://\*/" as an optional_permission. This lets you specify any origin in Permissions.origins as long as it has a matching scheme.

I've reopened the issue. I wanted it to stay open exactly for this kind of suggestions. Thank you @theckman for finding and sharing this!

I'm labeling it as _help wanted_.

@sindresorhus Let us know if you think providing options for this is not worth it.

@hkdobrev Ugh. My eyes went _right_ over that section. I'm sorry.

This extension provides a simple way of managing and enabling GHE:
https://github.com/buunguyen/octotree#enterprise-urls

After adding it to the list and saving, the browser prompts whether you want to allow it on that domain.

@mwakerman @theckman @thefotios Would one of you be interested in creating a pull request for this?

Sounds like this this is dependent on #193, correct? How else would this work?

@derimagia could easily add it as a one off option to input domain(s) and not worry about encompassing all possible options.

I tried this already, adding an option is not enough, you'll need to also inject the scripts manually. More info: https://github.com/npmhub/npmhub/pull/31#issuecomment-279136772

@bfred-it correct, you need to request permission for the site and then when on the site inject the scripts. Here's an example: https://github.com/buunguyen/octotree/blob/master/src/config/chrome/background.js

@busches @bfred-it Would one of you be willing to start a PR on this? I'm sure it will have good community support if any problems/questions arise. Many thanks!

鉃★笍 see how this was done in https://github.com/npmhub/npmhub/pull/31

My intention is to package those files up, that's why they're very generic and read directly from manifest.json. You may import them into a vendor folder for now.

Edit: done! 猬囷笍 馃帀

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  路  3Comments

Arcanemagus picture Arcanemagus  路  3Comments

juliocanares picture juliocanares  路  3Comments

alexanderadam picture alexanderadam  路  3Comments

olso picture olso  路  3Comments