| Index: stats.js | 
| =================================================================== | 
| --- a/stats.js | 
| +++ b/stats.js | 
| @@ -20,17 +20,16 @@ | 
| "use strict"; | 
|  | 
| (function() | 
| { | 
| const {require} = ext.backgroundPage.getWindow(); | 
|  | 
| const {getBlockedPerPage} = require("stats"); | 
| const {FilterNotifier} = require("filterNotifier"); | 
| -  const {Prefs} = require("prefs"); | 
|  | 
| let currentPage; | 
| const shareURL = "https://adblockplus.org/"; | 
|  | 
| let messageMark = {}; | 
| let shareLinks = { | 
| facebook: ["https://www.facebook.com/dialog/feed", { | 
| app_id: "475542399197328", | 
| @@ -73,17 +72,20 @@ | 
| return url + "?" + querystring.join("&"); | 
| } | 
|  | 
| function onLoad() | 
| { | 
| document.getElementById("share-box").addEventListener("click", share, | 
| false); | 
| let showIconNumber = document.getElementById("show-iconnumber"); | 
| -    showIconNumber.setAttribute("aria-checked", Prefs.show_statsinicon); | 
| +    ext.prefs.get("show_statsinicon", showStatsInIcon => | 
| +    { | 
| +      showIconNumber.setAttribute("aria-checked", showStatsInIcon); | 
| +    }); | 
| showIconNumber.addEventListener("click", toggleIconNumber, false); | 
| document.querySelector("label[for='show-iconnumber']").addEventListener( | 
| "click", toggleIconNumber, false | 
| ); | 
|  | 
| // Update stats | 
| ext.pages.query({active: true, lastFocusedWindow: true}, pages => | 
| { | 
| @@ -103,35 +105,45 @@ | 
|  | 
| function updateStats() | 
| { | 
| let statsPage = document.getElementById("stats-page"); | 
| let blockedPage = getBlockedPerPage(currentPage).toLocaleString(); | 
| i18n.setElementText(statsPage, "stats_label_page", [blockedPage]); | 
|  | 
| let statsTotal = document.getElementById("stats-total"); | 
| -    let blockedTotal = Prefs.blocked_total.toLocaleString(); | 
| -    i18n.setElementText(statsTotal, "stats_label_total", [blockedTotal]); | 
| +    ext.prefs.get("blocked_total", blockedTotal => | 
| +    { | 
| +      i18n.setElementText(statsTotal, "stats_label_total", | 
| +                          [blockedTotal.toLocaleString()]); | 
| +    }); | 
| } | 
|  | 
| function share(ev) | 
| { | 
| -    // Easter Egg | 
| -    let blocked = Prefs.blocked_total; | 
| -    if (blocked <= 9000 || blocked >= 10000) | 
| -      blocked = blocked.toLocaleString(); | 
| -    else | 
| -      blocked = i18n.getMessage("stats_over", (9000).toLocaleString()); | 
| +    ext.prefs.get("blocked_total", blockedTotal => | 
| +    { | 
| +      // Easter Egg | 
| +      if (blockedTotal <= 9000 || blockedTotal >= 10000) | 
| +        blockedTotal = blockedTotal.toLocaleString(); | 
| +      else | 
| +        blockedTotal = i18n.getMessage("stats_over", (9000).toLocaleString()); | 
|  | 
| -    ext.pages.open(createShareLink(ev.target.dataset.social, blocked)); | 
| +      ext.pages.open(createShareLink(ev.target.dataset.social, blockedTotal)); | 
| +    }); | 
| } | 
|  | 
| function toggleIconNumber() | 
| { | 
| -    Prefs.show_statsinicon = !Prefs.show_statsinicon; | 
| -    document.getElementById("show-iconnumber").setAttribute( | 
| -      "aria-checked", Prefs.show_statsinicon | 
| -    ); | 
| +    ext.prefs.toggle("show_statsinicon", () => | 
| +    { | 
| +      ext.prefs.get("show_statsinicon", showStatsInIcon => | 
| +      { | 
| +        document.getElementById("show-iconnumber").setAttribute( | 
| +          "aria-checked", showStatsInIcon | 
| +        ); | 
| +      }); | 
| +    }); | 
| } | 
|  | 
| document.addEventListener("DOMContentLoaded", onLoad, false); | 
| window.addEventListener("unload", onUnload, false); | 
| }()); | 
|  |