]> git.wh0rd.org Git - chrome-ext/tabs-backup.git/commitdiff
my customizations
authorMike Frysinger <vapier@gentoo.org>
Mon, 3 Jun 2019 15:03:24 +0000 (11:03 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sun, 26 Jan 2020 17:48:38 +0000 (12:48 -0500)
advanced.html
advanced.js
background.js
manifest.json
options.js
popup.js

index 57bf236482913483855e29784b34bb85ede0d95c..ecdb129e27391e7425cbbd248e12002345a06cab 100644 (file)
                        Restore selected <img src="icon_48.png" style="width: 26px;" />
                </div>
                <div id="restoreSelectedRadio">
-                       <input type="radio" id="restoreSelectedRadioSingleWindow" name="radio-1-set" class="regular-radio" checked />
+                       <input type="radio" id="restoreSelectedRadioSingleWindow" name="radio-1-set" class="regular-radio" />
                        <label for="restoreSelectedRadioSingleWindow" title="Restore all selected tabs into a single window"></label>
                        <span id="restoreSelectedRadioSingleWindowSpanLabel" class="radioSpanLabel" title="Restore all selected tabs into a single window"> Restore to a single window</span><br />
 
-                       <input type="radio" id="restoreSelectedRadioMultipleWindows" name="radio-1-set" class="regular-radio" />
+                       <input type="radio" id="restoreSelectedRadioMultipleWindows" name="radio-1-set" class="regular-radio" checked />
                        <label for="restoreSelectedRadioMultipleWindows" title="Restore selected tabs into their respective window"></label>
                        <span id="restoreSelectedRadioMultipleWindowsSpanLabel" class="radioSpanLabel" title="Restore selected tabs into their respective window"> Restore to multiple windows</span>
                </div>
index 9d48a66363e9f37dd166aab4a482baa835bd1bce..588e0567a4d37f8f153b98234fd4daa07f865d1e 100644 (file)
@@ -672,7 +672,7 @@ function menu_backupNow() {
 
        lastTimeBackupNowClicked = new Date().getTime();
 
-       chrome.extension.getBackgroundPage().backupNowManual(function(success, backupName, backupObj) {
+       chrome.runtime.getBackgroundPage((bg) => bg.backupNowManual(function(success, backupName, backupObj) {
                if (success) {
                        //updateBackupsList();
                        insertBackupItem (backupName, backupObj, true /*insertAtBeginning*/, true /*doAnimation*/);
@@ -682,12 +682,12 @@ function menu_backupNow() {
                } else {
                        alert('An error occured while creating the backup..');
                }
-       });
+       }));
 
 }
 
 function menu_restoreNow() {
-       chrome.extension.getBackgroundPage().restoreNow('full_backup');
+       chrome.runtime.getBackgroundPage((bg) => bg.restoreNow('full_backup'));
 }
 
 //document.onload(function () {
index a1debe5fa23a33dc0559c311c1618fcdea7e099a..6b6f89db93fbeb0694834d40552a9889e2a24cba 100644 (file)
@@ -1,19 +1,11 @@
 
 // Set default values if needed
 if (!localStorage.prefsMaxBackupItems) {
-       localStorage.prefsMaxBackupItems = "30";
+       localStorage.prefsMaxBackupItems = "10";
 }
 
 if (!localStorage.prefsBackupTimer) {
-       localStorage.prefsBackupTimer = "5";
-}
-
-if (!localStorage.lastTimerIntervalId) {
-       localStorage.lastTimerIntervalId = 0;
-}
-
-if (!localStorage.lastTabsEdit) {
-       localStorage.lastTabsEdit = 0;
+       localStorage.prefsBackupTimer = "30";
 }
 
 if (!localStorage.lastBackupTime) {
@@ -26,99 +18,18 @@ if (!localStorage.lastBackupTime) {
        backupNow(true, formattedDate, function(success, backupName, backupObj) {
                // backup completed
        });
-
-       localStorage.lastBackupTime = localStorage.lastTabsEdit;
-}
-
-
-
-// Works only for Event Pages
-/*
-chrome.runtime.onInstalled.addListener(function() {
-       console.log("Extension installed/updates");
-
-       if (localStorage.lastBackupTime != localStorage.lastTabsEdit) {
-               // Create a backup now
-               var d = new Date();
-               var formattedDate = date_format (d);
-
-               backupNow(true, formattedDate, function(success, backupName, backupObj) {
-                       // backup completed
-               });
-
-               localStorage.lastBackupTime = localStorage.lastTabsEdit;
-       }
-});*/
-
-chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
-       //console.log('tabs.onRemoved');
-
-       tabsEdited(true);
-});
-
-chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
-       //console.log('tabs.onUpdated');
-
-       tabsEdited(true);
-});
-
-chrome.tabs.onAttached.addListener(function(tabId, attachInfo) {
-       //console.log('tabs.onAttached');
-
-       tabsEdited(false);
-});
-
-chrome.tabs.onMoved.addListener(function(tabId, moveInfo) {
-       //console.log('tabs.onMoved');
-
-       tabsEdited(false);
-});
-
-chrome.tabs.onDetached.addListener(function(tabId, detachInfo) {
-       //console.log('tabs.onDetached');
-
-       tabsEdited(false);
-});
-
-chrome.tabs.onCreated.addListener(function(tab) {
-       //console.log('tabs.onCreated');
-
-       tabsEdited(true);
-});
-
-function tabsEdited (isImportant) {
-       var d = new Date();
-       var millis = d.getTime();
-
-       console.log('tabsEdited - lastTabsEdit: ' + localStorage.lastTabsEdit);
-       console.log('tabsEdited - new lastTabsEdit: ' + millis);
-
-       localStorage.lastTabsEdit = millis;
-
-
 }
 
 function initAlarm () {
-       console.log("initAlarm");
+       //console.log("initAlarm");
 
        var BACKUP_ALARM_NAME = "backup_alarm";
 
        // Clear any previous alarm
        chrome.alarms.clearAll();
-       clearInterval(parseInt(localStorage.lastTimerIntervalId));
 
        var timerMinutes = parseInt(localStorage.prefsBackupTimer);
-
-       // Apparantely once the app is on the Chrome Store it's not possible
-       // to create alarms that have period less than 5 minutes..
-       if (timerMinutes < 5) {
-               var timerMillis = timerMinutes * 60 * 1000;
-               localStorage.lastTimerIntervalId = setInterval (onAlarm, timerMillis);
-               console.log("Created interval alarm - id: " + localStorage.lastTimerIntervalId + " time: " + timerMinutes + " minutes");
-       } else {
-               console.log("Creating chrome.alarm 'backup_alarm' - time: " + timerMinutes + " minutes");
-               chrome.alarms.create(BACKUP_ALARM_NAME, {periodInMinutes: timerMinutes});
-       }
+       chrome.alarms.create(BACKUP_ALARM_NAME, {periodInMinutes: timerMinutes});
 }
 
 initAlarm();
@@ -127,12 +38,10 @@ function onAlarm (alarm) {
        var d = new Date();
        var formattedDate = date_format (d);
 
-       console.log("Alarm {" + alarm + "} fired up: " + formattedDate + " last tabs edit: " + localStorage.lastTabsEdit + " last backup time: " + localStorage.lastBackupTime);
+       console.log("Alarm {" + alarm + "} fired up: " + formattedDate);
 
-       // localStorage.lastBackupTime
        // if last backup time != lastTabsEdit
        //      perform automatic backup
-       if (localStorage.lastBackupTime != localStorage.lastTabsEdit) {
                backupNow(true, formattedDate, function(success, backupName, backupObj) {
                        // automatic backup completed
                        var popupViews = chrome.extension.getViews({type: "popup"});
@@ -148,9 +57,6 @@ function onAlarm (alarm) {
                                }
                        }
                });
-
-               localStorage.lastBackupTime = localStorage.lastTabsEdit;
-       }
 }
 
 chrome.alarms.onAlarm.addListener(onAlarm);
@@ -282,6 +188,9 @@ function backupNow(isAutomatic, backupName, callbackDone) {
                        fullBackup.windows.push(bkpWindow);
                }
 
+               if (totNumTabs == 0)
+                       return;
+
                fullBackup.totNumTabs = totNumTabs;
 
                var storageSetValues = {};
@@ -464,4 +373,4 @@ function restoreNow(backupName) {
 
                }
        });
-}
\ No newline at end of file
+}
index cd65f1dbf15b3dba1e6ebcbc391f7e128bd3cc8d..06162e67bb900f89846eecfb34bf136949946cf8 100644 (file)
@@ -1,12 +1,13 @@
 {
-  "name": "Tabs Backup & Restore",
-  "version": "0.2.1",
+  "name": "vapier tabs backup",
+  "version": "0.2.1.1",
   "manifest_version": 2,
   "description": "With 'Tabs Backup & Restore' you will never lose your work again! Backup an entire Chrome session (windows and tabs).",
   "icons": { "16": "icon_16.png",
            "48": "icon_48.png",
           "128": "icon_128.png" },
   "background": {
+       "persistent": false,
        "scripts": ["background.js"]
   },
   "options_page": "options.html",
index e443a8f177d30f9c638e992d50c83672d8af09f6..26d6d1ce1941024ff02f4d426c97a5d6517118ab 100644 (file)
@@ -33,7 +33,7 @@ function saveOptions () {
        localStorage.prefsMaxBackupItems = backupMaxItems;
 
        // Re-initialize the backup alarm
-       chrome.extension.getBackgroundPage().initAlarm();
+       chrome.runtime.getBackgroundPage((bg) => bg.initAlarm());
 
        // Update status to let user know options were saved.
        var status = document.getElementById("statusDiv");
index a8f1a04d29eb9b9777b466ef220203b483857024..7c5f2f5e3de8f1c8b51440dfbaa04859ad1535b4 100644 (file)
--- a/popup.js
+++ b/popup.js
@@ -140,7 +140,7 @@ function insertBackupItem (backupName, backupObj, insertAtBeginning, doAnimation
                return function(event) {
                        bootbox.confirm("Open Windows & Tabs of backup '" + backupName + "'?", function(confirmed) {
                                if (confirmed) {
-                                       chrome.extension.getBackgroundPage().restoreNow(backupName);
+                                       chrome.runtime.getBackgroundPage((bg) => bg.restoreNow(backupName));
                                }
                        });
 
@@ -157,8 +157,8 @@ function insertBackupItem (backupName, backupObj, insertAtBeginning, doAnimation
 
                        bootbox.confirm("Delete backup '" + backupName + "'?", function(confirmed) {
                                if (confirmed) {
-                                       chrome.extension.getBackgroundPage().deleteBackup(backupName, function() {
-                                               updateStorageInfo();
+                                       chrome.runtime.getBackgroundPage((bg) => {
+                                               bg.deleteBackup(backupName, () => updateStorageInfo());
                                        });
 
                                        //if (elem.parentNode) {
@@ -321,7 +321,7 @@ function menu_backupNow() {
 
        lastTimeBackupNowClicked = new Date().getTime();
 
-       chrome.extension.getBackgroundPage().backupNowManual(function(success, backupName, backupObj) {
+       chrome.runtime.getBackgroundPage((bg) => bg.backupNowManual(function(success, backupName, backupObj) {
                if (success) {
                        //updateBackupsList();
                        insertBackupItem (backupName, backupObj, true /*insertAtBeginning*/, true /*doAnimation*/);
@@ -331,12 +331,12 @@ function menu_backupNow() {
                } else {
                        alert('An error occured while creating the backup..');
                }
-       });
+       }));
 
 }
 
 function menu_restoreNow() {
-       chrome.extension.getBackgroundPage().restoreNow('full_backup');
+       chrome.runtime.getBackgroundPage((bg) => bg.restoreNow('full_backup'));
 }
 
 //document.onload(function () {