useful-forks.github.io
useful-forks.github.io copied to clipboard
userscript version of the Chrome extension
closes #20
menu to make it easy to add GITHUB_ACCESS_TOKEN or change it
show error if GITHUB_ACCESS_TOKEN has not been set up
hover color is adapted to GitHub's Night-Mode. (need better colors)
That is looking like some really great work: I'll review the PR in the coming days. Thanks a lot for your contribution !
Are you aware of whether it would be possible not to duplicate the JavaScript code used for the Chrome plugin ? I know refined-github
somehow manages to use the same code for all their supported browsers.
Maybe @fregante 's expertise could be helpful here.
(Sorry, I thought changing the title would link the other issue, but I ended up having to edit your OP.)
document.addEventListener('pjax:end', init);
Is that what fixes #9 ?
Also, does Violentmonkey require the script to be within that (function() { /* code */ })();
wrapper ?
document.addEventListener('pjax:end', init);
Is that what fixes #9 ?
yes , github use for some pages Pjax to deliver a faster browsing experience without reloading the full page. check this
does Violentmonkey require the script to be within that (function() { /* code */ })(); wrapper ?
i don't think so , just a habit
Would you mind creating 2 extra PRs for the fixes of #4 and #9 ? I'd do it myself, but I'll respect your "ownership" of the solutions, in case you wanted to be labeled as a contributor. I'd merge both those PRs into the Chrome script.
For this current PR, I don't have a lot of time to test it just yet. I'll eventually try to simply add your // ==UserScript==
right at the top of the Chrome script.
Alright, #25 was perfect, thanks for that!
I tried to incorporate your fix for #9 but couldn't get it to work properly. Have you tested if those cases work properly:
- landing directly on the Forks page (test with: https://github.com/useful-forks/useful-forks.github.io/network/members)
- refreshing the page when on the Forks page works (just press F5 when at the URL presented above)
Alright, now that I've incorporated both of your side-fixes into the main branch, it could be interesting to look into what this actually has to offer.
Have you tried incorporating your code directly into the Chrome plugin's script and seeing how well it works for people with and without Violentmonkey
?
Violentmonkey is an userscript manager this part of the script use a group of special apis provided only by an userscript manager.
// get token from local storage provided by the userscript manager.
let GITHUB_ACCESS_TOKEN = GM_getValue('GITHUB_ACCESS_TOKEN')
// add menu
GM_registerMenuCommand("Set Github Access Token", setPersonalToken)
GM_registerMenuCommand("Generate New Access Token", newPersonalToken);
// store token in local storage provided by the userscript manager.
function setPersonalToken(){
var mess = "Personal Access Token";
var caseShow = GITHUB_ACCESS_TOKEN;
var getpersonalToken = prompt(mess, caseShow);
GITHUB_ACCESS_TOKEN = (getpersonalToken===null? GITHUB_ACCESS_TOKEN : getpersonalToken)
GM_setValue("GITHUB_ACCESS_TOKEN", GITHUB_ACCESS_TOKEN)
}
// open url to generate a new personal token in new tab
function newPersonalToken(){
let tabControl = GM_openInTab("https://github.com/settings/tokens/new?scopes=repo&description=UsefulFork")
tabControl.onclose = () => setPersonalToken();
}
this should work in most other userscript managers (like Greasemonkey, Tampermonkey..)
My main concern is the duplication of code. Is there a way to integrate it within the chrome script in a non-intrusive way?
I'm already bothered by a large portion of the code being duplicated, I wouldn't want to have to maintain a third duplicate.
hey any news about this ?
Any update? This would be a great addition!
As mentioned, I'm kind of bothered by the duplication of code. See https://github.com/useful-forks/useful-forks.github.io/pull/21#issuecomment-849303400.
i'm kind of bothered by the duplication of code
what about creating a separate file that contain all shared functions and variables then simply include it to chrome script and userscript
what about creating a separate file that contain all shared functions and variables
Maybe that could work.
As a Java dev, what comes to mind is abstracting with an interface that has a few default methods for the shared ones, and then some different implementations for the Chrome and Monkey plugins.
The plugin has been heavily modified (see https://github.com/useful-forks/useful-forks.github.io/commit/63b9a3c49dd1bce9e1daf93dd4ea90bda002594e).
I'm closing the PR because it would basically need a rewrite anyways.