├── .gitignore ├── chrome-extension ├── img │ ├── icon_128.png │ ├── icon_19.png │ ├── icon_38.png │ └── icon_48.png ├── options.html ├── manifest.json ├── options.js └── white-space.js ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | /design-icon 2 | -------------------------------------------------------------------------------- /chrome-extension/img/icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyleladd/WhiteSpace-Bitbucket/master/chrome-extension/img/icon_128.png -------------------------------------------------------------------------------- /chrome-extension/img/icon_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyleladd/WhiteSpace-Bitbucket/master/chrome-extension/img/icon_19.png -------------------------------------------------------------------------------- /chrome-extension/img/icon_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyleladd/WhiteSpace-Bitbucket/master/chrome-extension/img/icon_38.png -------------------------------------------------------------------------------- /chrome-extension/img/icon_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kyleladd/WhiteSpace-Bitbucket/master/chrome-extension/img/icon_48.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WhiteSpace-Bitbucket 2 | 3 | Chrome extension to set options for white space in Bitbucket pull requests and commits: 4 | 5 | * Hide white-space differences. 6 | * Set white-space tab size. 7 | 8 | The extension is available in the Chrome web store here: 9 | [https://chrome.google.com/webstore/detail/white-space-diff-for-bitb/bkopdnhlifaaimncdeklkmlcllkfeahi](https://chrome.google.com/webstore/detail/white-space-diff-for-bitb/bkopdnhlifaaimncdeklkmlcllkfeahi) 10 | 11 | ## Help! 12 | 13 | Hello friendly coder! The org I'm with is no longer on Bitbucket. Since I'm not an active user anymore, I'm not maintaining this Chrome extension anymore. If you have interest in taking over this project, please let me know. 14 | 15 | Thanks! 16 | -------------------------------------------------------------------------------- /chrome-extension/options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | White Space Diff for Bitbucket Extension Options 5 | 16 | 17 | 18 | 19 | 20 |

21 | 25 |

26 | 27 |

28 | 32 |

33 | 34 |

35 | 38 | 39 | 40 |

41 | 42 |

43 | 44 |

45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /chrome-extension/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "White Space Diff for Bitbucket", 3 | "description" : "Set white space and tab size preferences for Bitbucket pull requests and commits.", 4 | 5 | "manifest_version" : 2, 6 | "version" : "2.0", 7 | 8 | "icons" : { 9 | "48" : "img/icon_48.png", 10 | "128" : "img/icon_128.png" 11 | }, 12 | "options_ui" : { 13 | "chrome_style" : true, 14 | "page" : "options.html" 15 | }, 16 | "page_action" : { 17 | "default_icon" : { 18 | "19" : "img/icon_19.png", 19 | "38" : "img/icon_38.png", 20 | "48" : "img/icon_48.png" 21 | }, 22 | "default_title" : "White Space Diff for Bitbucket" 23 | }, 24 | "content_scripts" : [ 25 | { 26 | "matches" : [ 27 | "https://bitbucket.org/*/commits/*", 28 | "https://bitbucket.org/*/pull-request/*/*", 29 | "https://bitbucket.org/*/pull-requests/*/*" 30 | ], 31 | "exclude_matches" : [ 32 | "https://bitbucket.org/*/new?*", 33 | "https://bitbucket.org/*/update/*" 34 | ], 35 | "js" : ["white-space.js"] 36 | } 37 | ], 38 | "permissions" : [ 39 | "https://bitbucket.org/*", 40 | "storage", 41 | "tabs" 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | 26 | -------------------------------------------------------------------------------- /chrome-extension/options.js: -------------------------------------------------------------------------------- 1 | 2 | // Saves options to chrome.storage.sync. 3 | function save_options() { 4 | 5 | var hideWS = document.getElementById('hide-ws').checked; 6 | var useTabs = document.getElementById('use-tabs').checked; 7 | var tabSpace = (useTabs) 8 | ? document.getElementById('tab-space').value 9 | : null 10 | ; 11 | 12 | chrome.storage.sync.set({ 13 | hideWS: hideWS, 14 | tabSpace: tabSpace, 15 | useTabs: useTabs, 16 | }, 17 | function() { 18 | 19 | // Update status to let user know options were saved. 20 | var status = document.getElementById('status'); 21 | status.className = ''; 22 | 23 | setTimeout(function() { 24 | status.className = 'invisible'; 25 | }, 2000); 26 | } 27 | ); 28 | } 29 | 30 | // Restores select box and checkbox state using the preferences 31 | // stored in chrome.storage. 32 | function restore_options() { 33 | 34 | // Use default values tabSpace = 4, useTabs = false. 35 | chrome.storage.sync.get({ 36 | hideWS: true, 37 | tabSpace: 4, 38 | useTabs: false 39 | }, 40 | function(items) { 41 | document.getElementById('hide-ws').checked = items.hideWS; 42 | document.getElementById('tab-space').value = items.tabSpace; 43 | document.getElementById('use-tabs').checked = items.useTabs; 44 | } 45 | ); 46 | } 47 | 48 | document.addEventListener('DOMContentLoaded', restore_options); 49 | document.getElementById('save').addEventListener('click', save_options); 50 | -------------------------------------------------------------------------------- /chrome-extension/white-space.js: -------------------------------------------------------------------------------- 1 | 2 | ;(function(){ 3 | 4 | // Extension scoped variables. 5 | var _qsArr = null; 6 | var _settings = null; 7 | 8 | var _methods = { 9 | 10 | init: function() { 11 | 12 | // Set querystring array. 13 | _qsArr = location.search.length 14 | ? location.search.replace('?', '').split('&') 15 | : [] 16 | ; 17 | 18 | _methods.setExtensionSettings(); 19 | 20 | // Wait for settings to populate. 21 | var settingsIntv = setInterval(function() { 22 | 23 | if (_settings) { 24 | 25 | clearInterval(settingsIntv); 26 | 27 | _methods.updateQueryString(); 28 | } 29 | 30 | }, 5); 31 | }, 32 | 33 | isTabsParamAdded: function() { 34 | 35 | if (! _settings.useTabs) return false; 36 | 37 | var tsParam = 'ts=' + _settings.tabSpace; 38 | 39 | if (_qsArr.indexOf(tsParam) == -1) { 40 | 41 | _qsArr.push(tsParam); 42 | return true; 43 | } 44 | 45 | return false; 46 | }, 47 | 48 | isWhiteSpaceParamAdded: function() { 49 | 50 | if (! _settings.hideWS) return false; 51 | 52 | var wsParam = 'w=1'; 53 | 54 | if (_qsArr.indexOf(wsParam) == -1) { 55 | 56 | _qsArr.push(wsParam); 57 | return true; 58 | } 59 | 60 | return false; 61 | }, 62 | 63 | setExtensionSettings: function() { 64 | 65 | // Get the extension settings and pass in defaults values. 66 | chrome.storage.sync.get({ 67 | hideWS: true, 68 | tabSpace: 4, 69 | useTabs: false 70 | }, 71 | function(settings) { 72 | 73 | // Set extension scoped variable to hold the extension's settings. 74 | _settings = settings; 75 | } 76 | ); 77 | }, 78 | 79 | updateQueryString: function() { 80 | 81 | // Find if any parameters where added to the query string. 82 | var isTabs = _methods.isTabsParamAdded(); 83 | var isWS = _methods.isWhiteSpaceParamAdded(); 84 | 85 | if (isTabs || isWS) { 86 | 87 | var url = location.pathname 88 | + '?' 89 | + _qsArr.join('&') 90 | + location.hash 91 | ; 92 | 93 | location.replace(url); 94 | } 95 | }, 96 | }; 97 | 98 | _methods.init(); 99 | 100 | })(); 101 | --------------------------------------------------------------------------------