Skip to content

Commit

Permalink
Fixed GHE
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyates committed Nov 2, 2016
1 parent 71b6bb3 commit e007326
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
13 changes: 11 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ function host(url) {
}

chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
var urls = gh_enterprise ? gh_enterprise.concat(",").concat("github.com") : "github.com";
var urls = ['github.com'];
if (gh_enterprise) {
gh_enterprise = gh_enterprise.replace('https://', '');
gh_enterprise = gh_enterprise.replace('http://', '');
urls.push(gh_enterprise);
}

urls = urls.split(',').map(host);
if (-1 !== urls.indexOf(host(tab.url))) {
chrome.pageAction.show(tabId);
if (tab.url.indexOf('github.com') < 0) {
chrome.tabs.insertCSS(null, {file: "pullrequest.css"});
chrome.tabs.executeScript(null, {file: "jquery-1.9.1.min.js"});
chrome.tabs.executeScript(null, {file: "pullrequest.js"});
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Pretty Pull Requests (Github)",
"description": "This extension applies various tweaks to the github pull-request code review pages.",
"version": "2.10.0",
"version": "2.10.1",
"icons": {
"32": "ppr-logo/32x32.png",
"64": "ppr-logo/64x64.png",
Expand All @@ -14,7 +14,7 @@
"scripts": ["background.js"]
},

"permissions" : ["tabs", "storage"],
"permissions" : ["tabs", "storage", "activeTab"],
"optional_permissions" : ["http://*/*", "https://*/*"],

"content_scripts": [
Expand Down
16 changes: 7 additions & 9 deletions pullrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var repositoryAuthor;
var autoCollapseExpressions;

function htmlIsInjected() {
return $('.pretty-pull-requests').length !== 0;
return $('.pretty-pull-requests-inserted').length > 0;
}

function injectHtml() {
Expand All @@ -18,6 +18,7 @@ function injectHtml() {
'</span>').insertAfter('.actions, .file-actions');

$('<div class="pretty-pull-requests bottom-collapse">Click to Collapse</div>').insertAfter('.data.highlight.blob-wrapper');
$('<div class="pretty-pull-requests-inserted" style="display: none"></div>').appendTo('body');
}

function collapseAdditions() {
Expand Down Expand Up @@ -178,6 +179,11 @@ chrome.storage.sync.get({url: '', saveCollapsedDiffs: true, tabSwitchingEnabled:
collectUniquePageInfo();
injectHtml();
initDiffs();

$body.on('click', '.user-select-contain, .js-selectable-text', clickTitle);
$body.on('click', '.bottom-collapse', clickCollapse);
$body.on('click', '.js-collapse-additions', collapseAdditions);
$body.on('click', '.js-collapse-deletions', collapseDeletions);
}
setTimeout(injectHtmlIfNecessary, 1000);
};
Expand All @@ -186,14 +192,6 @@ chrome.storage.sync.get({url: '', saveCollapsedDiffs: true, tabSwitchingEnabled:

injectHtmlIfNecessary();

$body.on('click', '.user-select-contain, .js-selectable-text', clickTitle);

$body.on('click', '.bottom-collapse', clickCollapse);

$body.on('click', '.js-collapse-additions', collapseAdditions);

$body.on('click', '.js-collapse-deletions', collapseDeletions);

if (items.tabSwitchingEnabled) {
$body.on('keydown', function (e) {
if (e.keyCode !== 192 || e.target.nodeName === 'TEXTAREA') {
Expand Down

0 comments on commit e007326

Please sign in to comment.