Last active
December 18, 2019 22:44
-
-
Save dance2die/7c79a1e09b334da6d723bd07e2bb7682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const code = `(function getUrls(){ | |
const forkUrl = document.querySelector('meta[name="octolytics-dimension-repository_parent_nwo"]') | |
? document.querySelector('meta[name="octolytics-dimension-repository_parent_nwo"]').content | |
: undefined; | |
const url = document.querySelector('meta[name="go-import"]') | |
? document.querySelector('meta[name="go-import"]').content.split(' ')[0] | |
: undefined; | |
const href = window.location.href; | |
return { forkUrl, url, href }; | |
})()`; | |
chrome.tabs.executeScript(tabId, { code }, function(result) { | |
const { forkUrl, url, href } = result[0]; | |
if (forkUrl) { | |
document.getElementById("url").innerText = ` | |
git remote add upstream https://github.com/${forkUrl} | |
git fetch upstream | |
git branch --set-upstream-to=upstream/master master`; | |
} else if (url) { | |
document.getElementById("url").innerText = ` | |
git remote add upstream https://${url} | |
git fetch upstream | |
git branch --set-upstream-to=upstream/master master`; | |
} else { | |
document.getElementById("url").innerText = ` | |
git remote add upstream ${href} | |
git fetch upstream | |
git branch --set-upstream-to=upstream/master master`; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment