├── README.md ├── background.js ├── icon_128.png ├── icon_19.png ├── icon_38.png ├── manifest.json ├── options.html ├── options.js ├── warning.html └── warning.js /README.md: -------------------------------------------------------------------------------- 1 | # Developer Profile Chrome Extension 2 | https://chrome.google.com/webstore/detail/developer-profile/pkpngjjbafobelnengjofedebcoofmff 3 | 4 | 5 | ![image](https://cloud.githubusercontent.com/assets/39191/6405074/e26f79b2-bdd3-11e4-95f4-d1c9920e4a22.png) 6 | 7 | 8 | This is a Google Chrome extension that deletes browser data when all windows in 9 | a profile are closed. It is best used in a profile that was specifically 10 | created for web development. 11 | 12 | It was created in response to [crbug.com/376788](http://crbug.com/376788): *devtools settings are ignored/reset in Incognito mode* 13 | 14 | 15 | ## License 16 | 17 | You may use this extension as long as you agree to not get mad at anyone 18 | besides yourself, and maybe your parents, when this extension does what is 19 | described. 20 | 21 | You may reuse the code in any way you see fit. It's not like I invented `if` 22 | statements. 23 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | var acknowledged = function() 2 | { 3 | if (!localStorage['warningAcknowledged']) 4 | { 5 | chrome.tabs.create({ 6 | 'url': 'warning.html' 7 | }); 8 | 9 | return false; 10 | } 11 | 12 | return true; 13 | }; 14 | 15 | var clearData = function(callback) 16 | { 17 | var dataTypes; 18 | 19 | try 20 | { 21 | dataTypes = JSON.parse(localStorage['dataTypes']); 22 | } 23 | catch(e) 24 | { 25 | dataTypes = { 26 | 'appcache': true, 27 | 'cache': true, 28 | 'cookies': true, 29 | 'downloads': true, 30 | 'fileSystems': true, 31 | 'formData': false, 32 | 'history': false, 33 | 'indexedDB': true, 34 | 'localStorage': true, 35 | 'pluginData': true, 36 | 'passwords': false, 37 | 'webSQL': true 38 | }; 39 | localStorage['dataTypes'] = JSON.stringify(dataTypes); 40 | } 41 | 42 | chrome.browsingData.remove({ 43 | 'since': 0 44 | }, dataTypes, function() 45 | { 46 | console.log('Cleared browser data.', dataTypes); 47 | callback && callback(); 48 | }); 49 | }; 50 | 51 | 52 | var clearTimer; 53 | 54 | chrome.tabs.onRemoved.addListener(function(tab, removeInfo) 55 | { 56 | if (!localStorage['warningAcknowledged']) 57 | { 58 | console.warn('User has not acknowledged the warning.'); 59 | return; 60 | } 61 | 62 | // If an entire window is closed, this event will fire again before the data is cleared 63 | localStorage['clearOnStartup'] = 'yes'; 64 | clearInterval(clearTimer); 65 | clearTimer = setTimeout(function() 66 | { 67 | chrome.windows.getAll({'populate': true}, function(windows) 68 | { 69 | var tabCount = 0; 70 | 71 | windows.forEach(function(w) 72 | { 73 | tabCount += w.tabs.length; 74 | }); 75 | 76 | if (!tabCount) 77 | { 78 | console.log('No tabs left. Clearing browser data...'); 79 | clearData(function() 80 | { 81 | localStorage['clearOnStartup'] = null; 82 | }); 83 | } 84 | }); 85 | }, 500); 86 | }); 87 | 88 | 89 | var badgeTimer; 90 | 91 | chrome.browserAction.onClicked.addListener(function(tab) 92 | { 93 | if (acknowledged()) 94 | { 95 | clearInterval(badgeTimer); 96 | chrome.browserAction.setBadgeText({'text': ' '}); 97 | chrome.browserAction.setBadgeBackgroundColor({'color': '#f39c12'}); 98 | clearData(function() 99 | { 100 | chrome.browserAction.setBadgeBackgroundColor({'color': '#2ecc71'}); 101 | badgeTimer = setTimeout(function() 102 | { 103 | chrome.browserAction.setBadgeText({'text': ''}); 104 | }, 500); 105 | }); 106 | } 107 | }); 108 | 109 | 110 | chrome.runtime.onStartup.addListener(function() 111 | { 112 | if (localStorage['warningAcknowledged'] && localStorage['clearOnStartup'] === 'yes') 113 | { 114 | console.warn('Data was not cleared in a previous session'); 115 | clearData(function() 116 | { 117 | localStorage['clearOnStartup'] = null; 118 | }); 119 | } 120 | }); 121 | 122 | 123 | chrome.runtime.onInstalled.addListener(function() 124 | { 125 | acknowledged(); 126 | }); 127 | -------------------------------------------------------------------------------- /icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweekmonster/Developer-Profile/25f3a936efe28352e58653af7e9bfe362ec750db/icon_128.png -------------------------------------------------------------------------------- /icon_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweekmonster/Developer-Profile/25f3a936efe28352e58653af7e9bfe362ec750db/icon_19.png -------------------------------------------------------------------------------- /icon_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tweekmonster/Developer-Profile/25f3a936efe28352e58653af7e9bfe362ec750db/icon_38.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Developer Profile", 4 | "description": "This extension deletes browser data when all windows in a profile are closed.", 5 | "version": "0.2", 6 | "icons": { 7 | "128": "icon_128.png", 8 | "38": "icon_38.png", 9 | "19": "icon_19.png" 10 | }, 11 | "browser_action": { 12 | "default_title": "Delete browsing data", 13 | "default_icon": { 14 | "19": "icon_19.png", 15 | "38": "icon_38.png" 16 | } 17 | }, 18 | "options_page": "options.html", 19 | "background": { 20 | "scripts": ["background.js"], 21 | "persistent": false 22 | }, 23 | "permissions": ["browsingData"] 24 | } 25 | -------------------------------------------------------------------------------- /options.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Developer Profile Options 6 | 49 | 50 | 51 | 52 |
53 |

Developer Profile

54 | 55 |

This extension will delete the following browser data when all windows in the current profile are closed.

56 | 57 |

(Clicking the trash icon will clear browser data, too)

58 |
59 |
60 | 67 | 74 | 81 | 88 | 95 | 102 | 109 | 116 | 123 | 130 | 137 | 144 | 151 |
152 | 153 | 154 | -------------------------------------------------------------------------------- /options.js: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function() 2 | { 3 | if (!localStorage['warningAcknowledged']) 4 | { 5 | window.location.href = 'warning.html'; 6 | return; 7 | } 8 | 9 | var updateSettings = function() 10 | { 11 | var dataTypes = {}; 12 | var inputs = document.getElementsByTagName('input'); 13 | for (var i = 0; i < inputs.length; i++) 14 | { 15 | dataTypes[inputs[i].getAttribute('name')] = inputs[i].checked; 16 | } 17 | 18 | localStorage['dataTypes'] = JSON.stringify(dataTypes); 19 | }; 20 | 21 | try 22 | { 23 | var dataTypes = JSON.parse(localStorage['dataTypes']); 24 | var input; 25 | for (var key in dataTypes) 26 | { 27 | document.getElementById(key).checked = dataTypes[key]; 28 | } 29 | } 30 | catch(e){}; 31 | 32 | var inputs = document.getElementsByTagName('input'); 33 | for (var i = 0; i < inputs.length; i++) 34 | { 35 | inputs[i].addEventListener('change', updateSettings); 36 | } 37 | }); 38 | -------------------------------------------------------------------------------- /warning.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | /!\ Attention 6 | 7 | 40 | 41 | 42 | 43 | 44 |

Attention

45 | 46 |

This extension will delete this profile's browser data when all windows are closed. 47 | If this is your main profile, you should remove this extension now and reinstall it on a profile you would expect this behavior on.

48 | 49 |

You must click the button below before this extension will work.

50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /warning.js: -------------------------------------------------------------------------------- 1 | document.addEventListener('DOMContentLoaded', function() 2 | { 3 | document.getElementById('acknowledge').addEventListener('click', function() 4 | { 5 | localStorage['warningAcknowledged'] = 'v0.2'; 6 | window.location.href = 'options.html'; 7 | }); 8 | }); 9 | --------------------------------------------------------------------------------