-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save options automatically (without button press), wording changes, a…
…nd indentation changes.
- Loading branch information
Showing
6 changed files
with
101 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>History Disabler</title> | ||
</head> | ||
<body> | ||
<h3>Advanced options</h3> | ||
<head> | ||
<title>History Disabler</title> | ||
</head> | ||
<body> | ||
<h3>Advanced options</h3> | ||
|
||
<p> | ||
<label> | ||
<input type="checkbox" id="download_option"> Disable download history. | ||
<br> | ||
<i style="color:red">Enabling this setting will have the browser forget a download as soon as the download is completed, or interrupted.</i> | ||
</label> | ||
</p> | ||
<p> | ||
<label> | ||
<input type="checkbox" id="download_option" style="top: -2px;"> | ||
<label for="download_option">Disable download history.</label> | ||
<br> | ||
<p style="color:red">Enabling this setting will cause the browser to forget a download as soon as the download is completed, or interrupted.</p> | ||
</label> | ||
</p> | ||
|
||
<p> | ||
<label> | ||
<input type="checkbox" id="tabs_option"> Retain 'Recently closed' tabs. | ||
<br> | ||
<i style="color:red">Enabling this setting will cause History Disabler not to clear the list of 'Recently closed' tabs for the session. This will enable, for example, the Ctrl-Shift-T keyboard shortcut to open recently closed tabs.</i> | ||
</label> | ||
</p> | ||
<p style="margin-top: 20px;"> | ||
<label> | ||
<input type="checkbox" id="tabs_option" style="top: -2px;"> | ||
<label for="tabs_option">Retain 'Recently closed' tabs.</label> | ||
<br> | ||
<p style="color:red">Enabling this setting will prevent clearing 'Recently closed' tabs for the session. This will enable, for example, the Ctrl-Shift-T keyboard shortcut to open recently closed tabs.</p> | ||
</label> | ||
</p> | ||
|
||
<p> | ||
<span> | ||
<button id="save">Apply settings</button> | ||
</span> | ||
<p align="center" style="color:grey"> | ||
Developed by <a href="https://aaronhorler.com">Aaron Horler</a> (aghorler) | <a href="https://github.com/aghorler/History-Disabler-for-Chromium">GitHub source</a> | ||
</p> | ||
|
||
<span id="status"></span> | ||
</p> | ||
|
||
<p align="center" style="color:grey"> | ||
Developed by Aaron Horler (aghorler) | <a href="https://github.com/aghorler/History-Disabler-for-Chromium">GitHub source</a> | ||
</p> | ||
|
||
<script src="/js/options.js"></script> | ||
</body> | ||
<script src="/js/options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
/* Function to clear all browsing history using the BrowsingData API. */ | ||
/* Function to clear all browsing history using the BrowsingData API. */ | ||
function clearBrowsingData(){ | ||
chrome.browsingData.removeHistory({ | ||
"originTypes": { | ||
"protectedWeb": true, | ||
"unprotectedWeb": true, | ||
"extension": true | ||
} | ||
}); | ||
chrome.browsingData.removeHistory({ | ||
"originTypes": { | ||
"protectedWeb": true, | ||
"unprotectedWeb": true, | ||
"extension": true | ||
} | ||
}); | ||
} | ||
|
||
/* Function to clear a specific item from history using the History API. */ | ||
/* Function to clear a specific item from history using the History API. */ | ||
function clearHistory(historyItem){ | ||
chrome.history.deleteUrl({ | ||
"url": historyItem | ||
}); | ||
chrome.history.deleteUrl({ | ||
"url": historyItem | ||
}); | ||
} | ||
|
||
/* Function to erase an item from download history using the Downloads API. */ | ||
/* Function to erase an item from download history using the Downloads API. */ | ||
function eraseDownload(downloadItem){ | ||
if(typeof downloadItem.state !== 'undefined'){ | ||
if(downloadItem.state.current === 'complete' || downloadItem.state.current === 'interrupted'){ | ||
chrome.downloads.erase({ | ||
limit: 1, | ||
id: downloadItem.id | ||
}); | ||
} | ||
} | ||
if(typeof downloadItem.state !== 'undefined'){ | ||
if(downloadItem.state.current === 'complete' || downloadItem.state.current === 'interrupted'){ | ||
chrome.downloads.erase({ | ||
limit: 1, | ||
id: downloadItem.id | ||
}); | ||
} | ||
} | ||
} | ||
|
||
/* Call clearHistory when a website is added to history. */ | ||
/* Call clearHistory when a website is added to history. */ | ||
chrome.history.onVisited.addListener(function(historyItem){ | ||
clearHistory(historyItem.url); | ||
clearHistory(historyItem.url); | ||
}); | ||
|
||
/* Call clearBrowsingData on tab close, if retain option is not enabled. | ||
This clears any browsing history listed in 'Recently closed' tabs. */ | ||
/* Call clearBrowsingData on tab close, if retain option is not enabled. | ||
This clears any browsing history listed in 'Recently closed' tabs. */ | ||
chrome.tabs.onRemoved.addListener(function(){ | ||
chrome.storage.local.get('retainTabs', function(option){ | ||
if(!option.retainTabs){ | ||
clearBrowsingData(); | ||
} | ||
}); | ||
chrome.storage.local.get('retainTabs', function(option){ | ||
if(!option.retainTabs){ | ||
clearBrowsingData(); | ||
} | ||
}); | ||
}); | ||
|
||
/* Call eraseDownload on download completion, if clear option is enabled. */ | ||
/* Call eraseDownload on download completion, if clear option is enabled. */ | ||
chrome.downloads.onChanged.addListener(function(downloadItem){ | ||
chrome.storage.local.get('clearDownloads', function(option){ | ||
if(option.clearDownloads){ | ||
eraseDownload(downloadItem); | ||
} | ||
}); | ||
chrome.storage.local.get('clearDownloads', function(option){ | ||
if(option.clearDownloads){ | ||
eraseDownload(downloadItem); | ||
} | ||
}); | ||
}); | ||
|
||
/* Call clearBrowsingData on browser start, and extension install. */ | ||
/* Call clearBrowsingData on browser start, and extension install. */ | ||
clearBrowsingData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
function saveOptions(){ | ||
var downloadOption = document.getElementById('download_option').checked; | ||
var tabsOption = document.getElementById('tabs_option').checked; | ||
chrome.storage.local.set({ | ||
clearDownloads: downloadOption, | ||
retainTabs: tabsOption | ||
}, function(){ | ||
var status = document.getElementById('status'); | ||
status.textContent = 'Options saved.'; | ||
status.style.color = "green"; | ||
setTimeout(function(){ | ||
status.textContent = ''; | ||
}, 750); | ||
}); | ||
var downloadOption = document.getElementById('download_option').checked; | ||
var tabsOption = document.getElementById('tabs_option').checked; | ||
chrome.storage.local.set({ | ||
clearDownloads: downloadOption, | ||
retainTabs: tabsOption | ||
}); | ||
} | ||
|
||
function restoreOptions(){ | ||
chrome.storage.local.get({ | ||
clearDownloads: false, | ||
retainTabs: false | ||
}, function(items){ | ||
document.getElementById('download_option').checked = items.clearDownloads; | ||
document.getElementById('tabs_option').checked = items.retainTabs; | ||
}); | ||
chrome.storage.local.get({ | ||
clearDownloads: false, | ||
retainTabs: false | ||
}, function(items){ | ||
document.getElementById('download_option').checked = items.clearDownloads; | ||
document.getElementById('tabs_option').checked = items.retainTabs; | ||
}); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', restoreOptions); | ||
document.getElementById('save').addEventListener('click', saveOptions); | ||
document.getElementById('download_option').addEventListener('change', saveOptions); | ||
document.getElementById('tabs_option').addEventListener('change', saveOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
{ | ||
"name": "History Disabler", | ||
"version": "1.5.2", | ||
"manifest_version": 2, | ||
"description": "Disable history in Chrome.", | ||
"background": { | ||
"scripts": ["/js/background.js"], | ||
"persistent": false | ||
}, | ||
"icons": { | ||
"128": "/img/icon128.png" | ||
}, | ||
"options_ui": { | ||
"name": "History Disabler", | ||
"version": "1.6", | ||
"manifest_version": 2, | ||
"description": "Disable history in Chrome.", | ||
"background": { | ||
"scripts": ["/js/background.js"], | ||
"persistent": false | ||
}, | ||
"icons": { | ||
"128": "/img/icon128.png" | ||
}, | ||
"options_ui": { | ||
"page": "/html/options.html", | ||
"chrome_style": true, | ||
"open_in_tab": false | ||
}, | ||
"permissions": [ | ||
"browsingData", | ||
"history", | ||
"downloads", | ||
"storage" | ||
] | ||
"permissions": [ | ||
"browsingData", | ||
"history", | ||
"downloads", | ||
"storage" | ||
] | ||
} |