Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src-chrome/main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
(function() {
var buttonElement = document.querySelector("a.get-repo-btn");
const divElement = document.querySelector('.get-repo-modal div ul');
if (!divElement) { return; }

if ( buttonElement === null ) {
return;
}
const linkElement = divElement.children[0].querySelector('a');

buttonElement.removeAttribute('href');
buttonElement.innerText = 'Open in Tower';
buttonElement.setAttribute('aria-label', buttonElement.getAttribute('aria-label').replace('GitHub Desktop', 'Tower'));
buttonElement.removeAttribute('data-open-app');
linkElement.removeAttribute('href');
linkElement.innerText = 'Open in Tower';
linkElement.removeAttribute('data-open-app');
linkElement.style.cursor = 'pointer';

buttonElement.addEventListener('click', function(event) {
linkElement.addEventListener('click', event => {
event.preventDefault();

var repoModalElement = buttonElement.parentElement.parentElement;
var inputElements = repoModalElement.querySelectorAll('input[type="text"]');
const data = JSON.parse(linkElement.getAttribute('data-hydro-click'));
let repositoryURL = data.payload.originating_url;

var repoModalElement = document.querySelector('.get-repo-modal');
var isSSH = repoModalElement.classList.contains('on');

var activeInputElement = inputElements[isSSH ? 1 : 0];
if (isSSH) {
repositoryURL = repositoryURL.replace('https://github.com/', 'git@github.com:');
}

window.location.href = 'gittower://openRepo/' + encodeURI(activeInputElement.value);
window.location.href = 'gittower://openRepo/' + encodeURI(repositoryURL);
});
}());
}());
18 changes: 10 additions & 8 deletions src-chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
{
"manifest_version": 2,

"permissions": [
"activeTab",
"declarativeContent"
],
"name": "Clone to Tower for Github",
"description": "Use Github's \"Open in Desktop\" Button with Tower",
"author": "Gerard Delmàs",
"homepage_url": "https://github.com/gdelmas/GithubTower",
"icons": {
"128": "icon.png"
},
"version": "1.2.0",

"content_scripts": [
{
"matches": ["*://github.com/*"],
"js": ["main.js"]
}
]
"version": "2.0.0",
"content_scripts": [{
"js": ["main.js"],
"matches": ["https://*.github.com/*"],
"all_frames": true
}]
}
31 changes: 17 additions & 14 deletions src-safari/GithubTower.safariextension/main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
(function() {
var buttonElement = document.querySelector("a.get-repo-btn");
const divElement = document.querySelector('.get-repo-modal div ul');
if (!divElement) { return; }

if ( buttonElement === null ) {
return;
}
const linkElement = divElement.children[0].querySelector('a');

buttonElement.removeAttribute('href');
buttonElement.innerText = 'Open in Tower';
buttonElement.setAttribute('aria-label', buttonElement.getAttribute('aria-label').replace('GitHub Desktop', 'Tower'));
buttonElement.removeAttribute('data-open-app');
linkElement.removeAttribute('href');
linkElement.innerText = 'Open in Tower';
linkElement.removeAttribute('data-open-app');
linkElement.style.cursor = 'pointer';

buttonElement.addEventListener('click', function(event) {
linkElement.addEventListener('click', event => {
event.preventDefault();

var repoModalElement = buttonElement.parentElement.parentElement;
var inputElements = repoModalElement.querySelectorAll('input[type="text"]');
const data = JSON.parse(linkElement.getAttribute('data-hydro-click'));
let repositoryURL = data.payload.originating_url;

var repoModalElement = document.querySelector('.get-repo-modal');
var isSSH = repoModalElement.classList.contains('on');

var activeInputElement = inputElements[isSSH ? 1 : 0];
if (isSSH) {
repositoryURL = repositoryURL.replace('https://github.com/', 'git@github.com:');
}

window.location.href = 'gittower://openRepo/' + encodeURI(activeInputElement.value);
window.location.href = 'gittower://openRepo/' + encodeURI(repositoryURL);
});
}());
}());