Commits

Anton Afanasyev committed 573d790

can permanently pause loading for the current domain - useful when things are
somehow broken for the current domain and you want to pause loading next pages
and page manually

Comments (0)

Files changed (1)

autopagerize.user.js

 
 var AutoPager = function(info) {
     this.info = info;
-    this.state = AUTO_START ? 'enable' : 'disable';
+    this.state = AUTO_START ? getEternalPausePreference( document.location.host ) : 'disable';
     this.shouldLoadAll = false;
     var self = this;
 
     
     SetupShortcutJs();
     
-    // AA - now add shortcuts
     var fnRemShortcuts = function(e) {
         shortcut.remove("Alt+]");
         shortcut.remove("Alt+\\");
         self.request();
     };
     var fnLoadPause = function(e) {
-        self.stateToggle();
+        return self.stateToggle();
+    };
+    var fnLoadPauseForever = function(e) {
+        var isEnabled = fnLoadPause();
+        setEternalPausePreference( this.document.location.host, isEnabled );
     };
     var fnLoadAll = function(e) {
         fnRemShortcuts();
     };
     shortcut.add("Alt+]",  fnLoadNext, {"type": "keypress"} );
     shortcut.add("Alt+\\", fnLoadPause, {"type": "keypress"} );
+    shortcut.add("Alt+/", fnLoadPauseForever, {"type": "keypress"} );
     shortcut.add("Alt+.",  fnLoadAll, {"type": "keypress"} );
 }
 
         this.enable();
         this.onScroll();
     }
+
+    return this.state == 'enable';
 }
 
 AutoPager.prototype.enable = function() {
         }
     }
 }
+
+
+var retrEternalPausePreferences = function() {
+    return eval(GM_getValue('eternalPause')) || {};
+}
+var saveEternalPausePreferences = function( prefs ) {
+    return GM_setValue( 'eternalPause', prefs.toSource() );
+}
+var setEternalPausePreference = function( domain, isPaused ) {
+    var prefs = retrEternalPausePreferences();
+
+    if( isPaused ) {
+        prefs[domain] = { isPaused:true };
+    } else {
+        delete prefs[domain];
+    }
+
+    saveEternalPausePreferences( prefs );
+}
+var getEternalPausePreference = function( domain ) {
+    var prefs = retrEternalPausePreferences();
+    var pref = prefs[domain];
+    if( pref )
+        return pref.isPaused || true;
+
+    return true;
+}
+
+
+
+
 var clearCache = function() {
     GM_setValue('cacheInfo', '');
 }