├── .github └── FUNDING.yml ├── LICENSE ├── README.md ├── css └── githubDiff.css ├── html └── popup.html ├── img ├── doc │ ├── demo.gif │ ├── ex-markdown.png │ ├── promo-small-tile.png │ ├── screenshot-markdown-default.png │ ├── screenshot-markdown-example.png │ ├── screenshot-no-changes.png │ ├── screenshot-nonmarkdown-example.png │ └── screenshot-wrong-tab.png ├── icon-128.png ├── icon-16.png ├── icon-48.png ├── icon-old.png ├── icon.png ├── next.png └── refresh.png ├── js ├── background.js ├── githubDiffNav.js └── popup.js └── manifest.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: daattali 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014-2018 Dean Attali 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Diff Navigator for GitHub (Chrome / Firefox extension) 2 | 3 | > *Copyright 2020 [Dean Attali](http://deanattali.com). Licensed under the MIT license.* 4 | 5 | _Source code available [on GitHub](https://github.com/daattali/github-diff-navigator-extension)_ 6 | _Get the [Chrome extension](https://chrome.google.com/webstore/detail/github-diff-navigator/aoojogkiedabnddmokieplfnmjehlneo) or [Firefox addon](https://addons.mozilla.org/addon/diff-navigator-for-github/)_ 7 | 8 | ## Installation 9 | 10 | Installation is extremely easy: just go to [the Chrome extension store](https://chrome.google.com/webstore/detail/github-diff-navigator/aoojogkiedabnddmokieplfnmjehlneo) or [Firefox add-ons page](https://addons.mozilla.org/addon/diff-navigator-for-github/) and install with one button click there. 11 | 12 | ## Description 13 | 14 | This is a Chrome extension that allows you to easily navigate through the changes in a file that has been edited on GitHub. 15 | 16 | You may have noticed that after editing a file through GitHub and previewing your changes, there is no easy way to navigate through the changes in a nice "next/previous change" manner. 17 | Most file formats only show the lines that were changed and several surrounding lines, so it's usually not a terrible inconvenience, but for any markdown document (`.md`) the situation is different. 18 | GitHub shows the entire markdown document when previewing the changes made, which means that if you're making a few tiny edits to a large document, it's very hard to find those edits and see what's changed. Rmarkdown (`.Rmd`) documents behave similarly, and potentially other markdown-type documents as well. 19 | 20 | Enter: GitHub Diff Navigator. 21 | 22 | 23 | ## Demo 24 | 25 | Here is a 20-second GIF that shows a demo of this extension: 26 | 27 | ![Demo](./img/doc/demo.gif) 28 | 29 | ## Motivation 30 | 31 | The idea for this extension came when I was reading through [Hadley Wickham's Advanced R book](http://adv-r.had.co.nz/). 32 | Every time I found a few typos in a chapter (which is a single markdown document), I would edit it on GitHub and make a pull request. 33 | To make sure I didn't make an idiot out of myself, I wanted to double-check my edits in the Preview tab, but I noticed the problem described above. I didn't trust my eyes in finding the few edits in such large files, and I ended up using the DOM + JavaScript console to help me find where the edits were. 34 | Then I decided that playing in the JavaScript console wasn't hardcore enough and I decided to spend the next two days making an extension that will help me find such changes quickly in the future. 35 | 36 | 37 | ## Features 38 | 39 | - GitHub Diff Navigator is non-intrusive and will only show up when looking at the Preview of edits made on a file using GitHub. 40 | - GitHub Diff Navigator will not take up any resources or show up in Chrome's Task Manager when you don't have a valid GitHub edited page open. 41 | - Works with multiple GitHub tabs that are open simultaneously (every time you switch tabs, the extension will update to show you the edits in that tab). 42 | - Automatically detect whether the file being edited is markdown-type or not, and seamlessly works for both. 43 | - Clean and intuitive UI with helpful messages shown when no edits are found. 44 | 45 | 46 | ## My other extensions 47 | 48 | [Old School GitHub](https://github.com/daattali/oldschool-github-extension) - GitHub rolled out a brand new UI on June 23, 2020. There are a few aspects of the new UI that I (and many others) don't like and this extension brings back a few features from the classic GitHub look. 49 | 50 | [Google Slides Auto Resize Speaker Notes](https://github.com/daattali/gslides-betternotes-extension) - the slides thumbnails in the Speaker Notes window of Google Slides are tiny. This extension dynamically resizes the slides to be more readable based on the window size. 51 | 52 | [Project Free TV Ad Bypass](https://github.com/daattali/pftv-ad-bypass-extension) - Project Free TV serves a 10-second ad page before allowing users to continue to the video - this extension bypasses the ad page. 53 | 54 | [Smileyfy My Facebook](https://github.com/daattali/smileyfy-my-facebook-extension) - Chrome extension that adds infinite happiness to your Facebook browsing, plus a little bonus rickrolling :) 55 | 56 | --- 57 | 58 | To see my other projects, visit [http://deanattali.com/projects](http://deanattali.com/projects) 59 | 60 | 61 | ## Disclaimer 62 | 63 | I would not advise using my code as a template or resource for learning how to write Chrome extensions. I learned how to write the extension and fully built it within two days, so I'm not sure what the best practices are and how to properly organize the code. It was just an excuse to test out how Chrome extensions work. I also left a little bit of ugly code in there -- please dont judge :) 64 | -------------------------------------------------------------------------------- /css/githubDiff.css: -------------------------------------------------------------------------------- 1 | body { 2 | width: 230px; 3 | text-align: center; 4 | } 5 | 6 | #github-diff-title { 7 | font-size:1.4em; 8 | margin-bottom: 10px; 9 | } 10 | 11 | #github-diff-ext-nav { 12 | font-size: 1.3em; 13 | margin-bottom: 5px; 14 | display: none; 15 | } 16 | 17 | #github-diff-ext-arrows { 18 | margin-top: 10px; 19 | } 20 | 21 | #github-diff-ext-nav .nav-arrow { 22 | width: 20px; 23 | height: 19px; 24 | cursor: pointer; 25 | } 26 | 27 | #github-diff-ext-nav .nav-arrow:hover { 28 | opacity: 0.9; 29 | } 30 | 31 | #github-diff-ext-nav .nav-arrow:active { 32 | opacity: 0.7; 33 | } 34 | 35 | #github-diff-ext-prev { 36 | transform: scale(-1, 1); 37 | } 38 | 39 | #github-diff-ext-msg { 40 | font-size: 1.1em; 41 | } 42 | 43 | #github-diff-footer { 44 | margin-top: 7px; 45 | position: relative; 46 | } 47 | 48 | #github-diff-copyright { 49 | color: #888888; 50 | font-size: 1em; 51 | } 52 | 53 | #github-diff-link { 54 | text-decoration: underline; 55 | cursor: pointer; 56 | color: inherit; 57 | } 58 | 59 | #github-diff-ext-refresh { 60 | width: 14px; 61 | height: 14px; 62 | position: absolute; 63 | right: 0; 64 | cursor: pointer; 65 | } 66 | 67 | #github-diff-ext-refresh:hover { 68 | transform: rotate(45deg); 69 | } 70 | 71 | #github-diff-ext-refresh:active { 72 | opacity: 0.7; 73 | } -------------------------------------------------------------------------------- /html/popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GitHub Diff Navigator 5 | 6 | 7 | 8 | 9 | 10 |
GitHub Diff Navigator

11 |
12 |
13 | Edit 14 | 15 | of 16 | 17 |
18 |
19 | Previous change 20 | Next change 21 |
22 |
23 |
24 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /img/doc/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/demo.gif -------------------------------------------------------------------------------- /img/doc/ex-markdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/ex-markdown.png -------------------------------------------------------------------------------- /img/doc/promo-small-tile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/promo-small-tile.png -------------------------------------------------------------------------------- /img/doc/screenshot-markdown-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/screenshot-markdown-default.png -------------------------------------------------------------------------------- /img/doc/screenshot-markdown-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/screenshot-markdown-example.png -------------------------------------------------------------------------------- /img/doc/screenshot-no-changes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/screenshot-no-changes.png -------------------------------------------------------------------------------- /img/doc/screenshot-nonmarkdown-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/screenshot-nonmarkdown-example.png -------------------------------------------------------------------------------- /img/doc/screenshot-wrong-tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/doc/screenshot-wrong-tab.png -------------------------------------------------------------------------------- /img/icon-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/icon-128.png -------------------------------------------------------------------------------- /img/icon-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/icon-16.png -------------------------------------------------------------------------------- /img/icon-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/icon-48.png -------------------------------------------------------------------------------- /img/icon-old.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/icon-old.png -------------------------------------------------------------------------------- /img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/icon.png -------------------------------------------------------------------------------- /img/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/next.png -------------------------------------------------------------------------------- /img/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daattali/github-diff-navigator-extension/5bb52e1f3e18927fdb0fa11461c2962c2695fbe8/img/refresh.png -------------------------------------------------------------------------------- /js/background.js: -------------------------------------------------------------------------------- 1 | var githubDiffBackground = { 2 | 3 | curIdx : 0, 4 | total : 0, 5 | diffIds : [], 6 | doctype : "", 7 | 8 | // init: add listeners 9 | init : function() { 10 | chrome.runtime.onInstalled.addListener(function() { 11 | // Replace all rules ... 12 | chrome.declarativeContent.onPageChanged.removeRules(undefined, function() { 13 | // With a new rule ... 14 | chrome.declarativeContent.onPageChanged.addRules([ 15 | { 16 | // That fires when a page's URL is in a github edit page 17 | conditions: [ 18 | new chrome.declarativeContent.PageStateMatcher({ 19 | pageUrl: { urlMatches: '.*/github.com/.*/edit/.*' }, 20 | }) 21 | ], 22 | // And shows the extension's page action. 23 | actions: [ new chrome.declarativeContent.ShowPageAction() ] 24 | } 25 | ]); 26 | }); 27 | }); 28 | 29 | chrome.runtime.onMessage.addListener( 30 | function(request, sender) { 31 | // when the extension refreshed, save all the data and refresh the UI 32 | if (request.action == "refreshed") { 33 | githubDiffBackground.diffIds = request.diffIds; 34 | githubDiffBackground.curIdx = 0; 35 | githubDiffBackground.total = request.diffIds.length; 36 | githubDiffBackground.doctype = request.doctype; 37 | 38 | githubDiffBackground.refreshView(true); 39 | } 40 | } 41 | ) 42 | }, 43 | 44 | getCurIdx : function() { 45 | return githubDiffBackground.curIdx; 46 | }, 47 | 48 | getTotal : function() { 49 | return githubDiffBackground.total; 50 | }, 51 | 52 | getDoctype : function() { 53 | return githubDiffBackground.doctype; 54 | }, 55 | 56 | getDiffIds : function() { 57 | return githubDiffBackground.diffIds; 58 | }, 59 | 60 | prevClick : function() { 61 | githubDiffBackground.curIdx--; 62 | if (githubDiffBackground.curIdx < 1) { 63 | githubDiffBackground.curIdx = githubDiffBackground.total; 64 | } 65 | githubDiffBackground.refreshView(); 66 | githubDiffBackground.highlightDiff(); 67 | }, 68 | 69 | nextClick : function() { 70 | githubDiffBackground.curIdx++; 71 | if (githubDiffBackground.curIdx > githubDiffBackground.total) { 72 | githubDiffBackground.curIdx = 1; 73 | } 74 | githubDiffBackground.highlightDiff(); 75 | githubDiffBackground.refreshView(); 76 | }, 77 | 78 | refreshView : function(complete) { 79 | var viewTabUrl = chrome.extension.getURL('popup.html'); 80 | var views = chrome.extension.getViews({type: "popup"}); 81 | var view = views[0]; 82 | view.githubDiffPopup.refreshView(complete); 83 | }, 84 | 85 | highlightDiff : function() { 86 | var curId = githubDiffBackground.diffIds[githubDiffBackground.curIdx - 1]; 87 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { 88 | chrome.tabs.sendMessage(tabs[0].id, 89 | {action: "highlightDiff", el: curId}); 90 | }); 91 | } 92 | } 93 | 94 | githubDiffBackground.init(); 95 | -------------------------------------------------------------------------------- /js/githubDiffNav.js: -------------------------------------------------------------------------------- 1 | var githubDiffNav = { 2 | 3 | // init: add message listeners and call the appropriate function based on the request 4 | init : function() { 5 | chrome.runtime.onMessage.addListener( 6 | function(request, sender, sendResponse) { 7 | if (request.action == "refresh") { 8 | githubDiffNav.refreshDiffEls(); 9 | } else if (request.action == "highlightDiff") { 10 | githubDiffNav.highlightDiff(request.el); 11 | } else if (request.action == "isInPreviewTab") { 12 | sendResponse({isInPreviewTab : githubDiffNav.isInPreviewTab()}); 13 | } else if (request.action == "isDiffOutdated") { 14 | sendResponse({isDiffOutdated : githubDiffNav.isDiffOutdated(request.diffIds)}); 15 | } 16 | } 17 | ); 18 | }, 19 | 20 | // refreshDiffEls: look at the page's DOM and find all the elements that are changed 21 | refreshDiffEls : function() { 22 | // find the elements depending on the file type 23 | if (document.getElementsByClassName("markdown-body").length > 0) { // diff view for markdown files 24 | var githubDiffEls = document.querySelectorAll(".prose-diff .markdown-body>ins, .prose-diff .markdown-body>del, .rich-diff-level-zero.changed"); 25 | var doctype = "Markdown"; 26 | } else { // any non-markdown file 27 | // get all edited sections by first getting all editted lines and then 28 | // only keeping the first line from a section of consecutive lines 29 | var githubDiffCells = document.querySelectorAll("td.blob-num-addition, td.blob-num-deletion"); 30 | var githubDiffEls = []; 31 | var lastRow = null; 32 | for (var i = 0; i < githubDiffCells.length; i++) { 33 | var el = githubDiffCells[i]; 34 | var rowEl = el.parentNode; 35 | if (i == 0 || (rowEl != lastRow && rowEl.previousElementSibling != lastRow)) { 36 | githubDiffEls.push(rowEl); 37 | } 38 | lastRow = rowEl; 39 | } 40 | var doctype = "Non-markdown"; 41 | } 42 | 43 | // Since we cannot pass DOM elements using JSON, we need to pass a reference to them. 44 | // Make sure every element has an ID (create a random one if it doesn't), and send those ids 45 | var githubDiffIds = []; 46 | for (var i = 0; i < githubDiffEls.length; i++) { 47 | var el = githubDiffEls[i]; 48 | if(!el.id) { 49 | el.id = "github-diff-el_" + Math.floor(Math.random() * 10000000000); 50 | } 51 | githubDiffIds.push(el.id); 52 | } 53 | 54 | chrome.runtime.sendMessage({action: "refreshed", 55 | diffIds: githubDiffIds, 56 | doctype: doctype}); 57 | }, 58 | 59 | // highlightDiff: given a DOM element, scroll it into the view pane 60 | highlightDiff : function(el) { 61 | var el = document.getElementById(el); 62 | el.scrollIntoView(); 63 | }, 64 | 65 | // isInPreviewTab: determine if the user is currently on the Preview tab or not 66 | isInPreviewTab : function() { 67 | return document.getElementsByClassName("tabnav-tab selected preview").length > 0; 68 | }, 69 | 70 | // isDiffOutdated: determine if the diffs in the Preview tab are outdated 71 | // (outdated means that the user switched tabs and now the DOM has been rewritten 72 | // or that there were previously no changes) 73 | isDiffOutdated : function(diffIds) { 74 | if (diffIds.length == 0) return true; 75 | 76 | for (var i = 0; i < diffIds.length; i++) { 77 | var el = diffIds[i]; 78 | if (!document.getElementById(el)) { 79 | return true; 80 | } 81 | } 82 | return false; 83 | } 84 | } 85 | 86 | githubDiffNav.init(); 87 | -------------------------------------------------------------------------------- /js/popup.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Dean Attali 3 | * December 2014 4 | */ 5 | 6 | var githubDiffPopup = { 7 | 8 | // init: when the user clicks on the extension icon, initialize the UI and add listeners on buttons 9 | init : function() { 10 | githubDiffPopup.initUi(); 11 | document.getElementById("github-diff-ext-refresh").addEventListener("click", githubDiffPopup.refreshClick); 12 | document.getElementById("github-diff-ext-prev").addEventListener("click", githubDiffPopup.prevClick); 13 | document.getElementById("github-diff-ext-next").addEventListener("click", githubDiffPopup.nextClick); 14 | }, 15 | 16 | // initUi: initialize the UI from opening the extension 17 | initUi : function() { 18 | githubDiffPopup.refreshUiInit(false); 19 | }, 20 | 21 | // refreshClick: initialize the UI from clicking on Refresh 22 | refreshClick : function() { 23 | githubDiffPopup.refreshUiInit(true); 24 | }, 25 | 26 | // refreshUiInit: refresh the UI 27 | /* This function is a little messy and definitely not coded in a nice way, 28 | but it's 4am and I worked on it for 2 days straight, so screw it :) 29 | Logic: First, make sure the user is in the Preview tab. If not, show a message and quit. 30 | If the Refresh button was clicked, then perform a refresh right away. 31 | If we're here trying to do an automatic refresh because the extension was just opened, 32 | first try to see if a refresh is necessary: if there were previously no changes or if the 33 | previous changes are outdated (the DOM has been rewritten since), then perform an update. 34 | */ 35 | refreshUiInit : function(force) { 36 | var cb = function(bg) { 37 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { 38 | chrome.tabs.sendMessage(tabs[0].id, 39 | {action: "isInPreviewTab"}, 40 | function(response) { 41 | if (!response.isInPreviewTab) { 42 | githubDiffPopup.notInPreviewTabMsg(); 43 | } else { 44 | if (force) { 45 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { 46 | chrome.tabs.sendMessage(tabs[0].id, {action: "refresh"}); 47 | }); 48 | } else { 49 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { 50 | chrome.tabs.sendMessage(tabs[0].id, 51 | {action: "isDiffOutdated", diffIds: bg.githubDiffBackground.getDiffIds()}, 52 | function(response) { 53 | if (response.isDiffOutdated) { 54 | chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { 55 | chrome.tabs.sendMessage(tabs[0].id, {action: "refresh"}); 56 | }); 57 | } else { 58 | githubDiffPopup.refreshView(true); 59 | } 60 | }); 61 | }); 62 | } 63 | } 64 | }); 65 | }); 66 | }; 67 | 68 | chrome.runtime.getBackgroundPage(cb); 69 | }, 70 | 71 | prevClick : function() { 72 | var cb = function(bg) { 73 | bg.githubDiffBackground.prevClick(); 74 | }; 75 | chrome.runtime.getBackgroundPage(cb); 76 | }, 77 | 78 | nextClick : function() { 79 | var cb = function(bg) { 80 | bg.githubDiffBackground.nextClick(); 81 | }; 82 | chrome.runtime.getBackgroundPage(cb); 83 | }, 84 | 85 | refreshNav : function() { 86 | githubDiffPopup.refreshNavCur(); 87 | githubDiffPopup.refreshNavTotal(); 88 | }, 89 | 90 | refreshNavCur : function() { 91 | var cb = function(bg) { 92 | var num = bg.githubDiffBackground.getCurIdx(); 93 | document.getElementById("github-diff-ext-cur").innerHTML = num; 94 | }; 95 | chrome.runtime.getBackgroundPage(cb); 96 | }, 97 | 98 | refreshNavTotal : function() { 99 | var cb = function(bg) { 100 | var num = bg.githubDiffBackground.getTotal(); 101 | document.getElementById("github-diff-ext-total").innerHTML = num; 102 | }; 103 | chrome.runtime.getBackgroundPage(cb); 104 | }, 105 | 106 | notInPreviewTabMsg : function() { 107 | document.getElementById("github-diff-ext-nav").style.display = 'none'; 108 | document.getElementById("github-diff-ext-msg").innerHTML = "It doesn't seem like you're in the \"Preview changes\" tab."; 109 | }, 110 | 111 | refreshTitle : function() { 112 | var cb = function(bg) { 113 | var doctype = bg.githubDiffBackground.getDoctype(); 114 | var total = bg.githubDiffBackground.getTotal(); 115 | 116 | if (total == 0) { 117 | document.getElementById("github-diff-ext-nav").style.display = 'none'; 118 | document.getElementById("github-diff-ext-msg").innerHTML = "No changes found in this GitHub edit."; 119 | return; 120 | } 121 | 122 | document.getElementById("github-diff-ext-nav").style.display = 'block'; 123 | document.getElementById("github-diff-ext-msg").innerHTML = doctype + " file"; 124 | }; 125 | chrome.runtime.getBackgroundPage(cb); 126 | }, 127 | 128 | refreshView : function(complete) { 129 | githubDiffPopup.refreshNav(); 130 | if (typeof(complete) !== 'undefined' && complete) { 131 | githubDiffPopup.refreshTitle(); 132 | } 133 | } 134 | } 135 | 136 | document.addEventListener('DOMContentLoaded', function () { 137 | githubDiffPopup.init(); 138 | }); -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Diff Navigator for GitHub", 3 | "version": "1.0", 4 | "manifest_version": 2, 5 | "description": "GitHub Diff Navigator allows you to easily navigate through the changes in a file that has been edited on GitHub.", 6 | "page_action": { 7 | "default_title": "Diff Navigator for GitHub", 8 | "default_popup": "html/popup.html" 9 | }, 10 | "background": { 11 | "scripts": ["js/background.js"], 12 | "persistent": false 13 | }, 14 | "permissions" : [ 15 | "declarativeContent" 16 | ], 17 | "icons": { 18 | "16": "img/icon-16.png", 19 | "48": "img/icon-48.png", 20 | "128": "img/icon-128.png" 21 | }, 22 | "content_scripts": [ 23 | { 24 | "matches": [ 25 | "https://github.com/*/edit/*", 26 | "http://github.com/*/edit/*" 27 | ], 28 | "js": [ 29 | "js/githubDiffNav.js" 30 | ] 31 | } 32 | ], 33 | "homepage_url": "https://github.com/daattali/github-diff-navigator-extension" 34 | } 35 | --------------------------------------------------------------------------------