| Index: go-back-with-backspace/content_script.js
|
| diff --git a/go-back-with-backspace/content_script.js b/go-back-with-backspace/content_script.js
|
| index f80ab2a2b3eab5adedfd2c31ba8c9b1ea571fe0c..820ed255e271501a8fb628eb1fc8aac8c75ec22d 100644
|
| --- a/go-back-with-backspace/content_script.js
|
| +++ b/go-back-with-backspace/content_script.js
|
| @@ -12,8 +12,14 @@ chrome.storage.sync.get({
|
| whitelist: []
|
| }, function(items) {
|
| options = items;
|
| - window.addEventListener('keydown', function(e) {
|
| - handleBackspace(e);
|
| + window.addEventListener('keydown', handleBackspace);
|
| +
|
| + // Set up a longstanding connection to the background page. When the
|
| + // extension updates, is disabled, or is uninstalled, this connection will
|
| + // drop, and we will know to remove the listener.
|
| + var port = chrome.runtime.connect();
|
| + port.onDisconnect.addListener(function(port) {
|
| + window.removeEventListener('keydown', handleBackspace);
|
| });
|
| });
|
|
|
| @@ -36,7 +42,8 @@ function handleBackspace(e) {
|
| e.key !== 'Backspace' ||
|
| e.altKey ||
|
| e.ctrlKey ||
|
| - e.metaKey)
|
| + e.metaKey ||
|
| + window.history.length < 2) // Nowhere to go back or forward to anyway.
|
| return;
|
|
|
| // The blacklist overrides everything.
|
| @@ -69,8 +76,11 @@ function disabledInApplet(target) {
|
| var nodeType = target.type || '';
|
| nodeType = nodeType.toLowerCase();
|
| if ((nodeName === 'EMBED' || nodeName === 'OBJECT') &&
|
| - (nodeType === 'application/x-shockwave-flash' ||
|
| - nodeType === 'application/java')) {
|
| + (nodeType === 'application/java' ||
|
| + nodeType === 'application/pdf' ||
|
| + nodeType === 'application/x-chat' ||
|
| + nodeType === 'application/x-google-chrome-pdf' ||
|
| + nodeType === 'application/x-shockwave-flash')) {
|
| return true;
|
| }
|
| return false;
|
|
|