├── GithubObjCExt.crx ├── README.md └── src ├── events.js └── manifest.json /GithubObjCExt.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JaviSoto/Github-JumpToObjCCounterPart-ChromeExt/196c6cd04388dc97cff289a5ad703f59c0ba51ce/GithubObjCExt.crx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Description 2 | `Control+Command+Up` shortcut to navigate between header and implementation in Objective-C files in Github. 3 | 4 | # Install 5 | 6 | Click [here](https://github.com/JaviSoto/Github-JumpToObjCCounterPart-ChromeExt/blob/master/GithubObjCExt.crx?raw=true) to download and install in Chrome. 7 | -------------------------------------------------------------------------------- /src/events.js: -------------------------------------------------------------------------------- 1 | function jumpToCounterPathFile() { 2 | chrome.tabs.query({ currentWindow: true, active: true }, function (tab) { 3 | if (tab === undefined) { 4 | console.log("Couldn't get the current tab"); 5 | return; 6 | } 7 | 8 | var currentTab = tab[0]; 9 | var tabURL = currentTab.url; 10 | 11 | var URLIsInGithubDomain = (tabURL.indexOf("https://github.com/") === 0); 12 | if (!URLIsInGithubDomain) { 13 | return; 14 | } 15 | 16 | var URLIsObjCClassURLRegExp = /(.*\.)(h|m)/; 17 | var URLAndObjCExtension = URLIsObjCClassURLRegExp.exec(tabURL); 18 | 19 | if (URLAndObjCExtension !== null) { 20 | var URLWithoutExtension = URLAndObjCExtension[1]; 21 | var extension = URLAndObjCExtension[2]; 22 | 23 | var newExtension = extension == "h" ? "m" : "h"; 24 | 25 | var newURL = URLWithoutExtension + newExtension; 26 | 27 | chrome.tabs.update(tab.id, { url: newURL}); 28 | } 29 | }); 30 | } 31 | 32 | 33 | chrome.commands.onCommand.addListener(function(command) { 34 | if (command == "jump-to-counter-part") { 35 | jumpToCounterPathFile(); 36 | } 37 | else { 38 | throw "Unknown command " + command; 39 | } 40 | }); 41 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | 4 | "name": "Jump to Objective-C counterpart file in Github", 5 | "version": "1.0", 6 | "description": "Control+Command+Up shortcut to navigate between header and implementation in Objective-C files in Github.", 7 | 8 | "background": { 9 | "scripts": ["events.js"], 10 | "persistent": false 11 | }, 12 | 13 | "commands": { 14 | "jump-to-counter-part": { 15 | "suggested_key": { 16 | "mac": "MacCtrl+Command+Up" 17 | }, 18 | 19 | "description": "Jump to counterpart" 20 | } 21 | }, 22 | 23 | "permissions": [ 24 | "activeTab" 25 | ] 26 | } 27 | --------------------------------------------------------------------------------