diff --git a/src/icon19.png b/src/icon19.png
new file mode 100644
index 0000000..737ab56
Binary files /dev/null and b/src/icon19.png differ
diff --git a/src/icon38.png b/src/icon38.png
new file mode 100644
index 0000000..bdda591
Binary files /dev/null and b/src/icon38.png differ
diff --git a/src/js/src/notifier.js b/src/js/src/notifier.js
new file mode 100644
index 0000000..9f7a59c
--- /dev/null
+++ b/src/js/src/notifier.js
@@ -0,0 +1,75 @@
+/* Notifier icon */
+
+if (!faextender) { var faextender = {}; }
+
+faextender.Notifier = {
+ Start: function() {
+ chrome.browserAction.onClicked.addListener(faextender.Notifier.OnClick);
+ chrome.storage.sync.get("notifier_delay", faextender.Notifier.VarCheck);
+ chrome.storage.onChanged.addListener(faextender.Notifier.VarChanged);
+ },
+
+ VarCheck: function(obj) {
+ faextender.Notifier.Options = obj;
+ faextender.Notifier.Init();
+ },
+
+ VarChanged: function(changes, namespace) {
+ if (namespace == "sync") {
+ var delayChange = changes["notifier_delay"];
+ if (delayChange) {
+ faextender.Notifier.Options.notifier_delay = delayChange.newValue;
+ faextender.Notifier.ChangeAlarmDuration();
+ }
+ }
+ },
+
+ Options: null,
+ MatchRegex: new RegExp("
(\\d+) messages"),
+
+ Init: function() {
+ chrome.alarms.onAlarm.addListener(faextender.Notifier.OnAlarm);
+ faextender.Notifier.ChangeAlarmDuration();
+ },
+
+ ChangeAlarmDuration: function() {
+ try {
+ chrome.alarms.clear("notifier_check");
+ }
+ catch (e) { /* No way to avoid an exception */ }
+
+ var delay = faextender.Notifier.Options.notifier_delay;
+ if ((!delay) || (delay < 1)) {
+ faextender.Notifier.UpdateBadge("");
+ return;
+ };
+
+ chrome.alarms.create("notifier_check", { periodInMinutes: delay });
+ faextender.Notifier.UpdateCheck();
+ },
+
+ OnAlarm: function(alarm) {
+ if (alarm.name == "notifier_check") {
+ faextender.Notifier.UpdateCheck();
+ }
+ },
+
+ UpdateCheck: function() {
+ $.get("https://www.furaffinity.net/controls/messages/", function(data) {
+ var result = data.match(faextender.Notifier.MatchRegex);
+ if (result[1]) {
+ faextender.Notifier.UpdateBadge(result[1]);
+ }
+ });
+ },
+
+ UpdateBadge: function(val) {
+ chrome.browserAction.setBadgeText({ "text": val });
+ },
+
+ OnClick: function(tab) {
+ window.open("https://www.furaffinity.net/");
+ }
+}
+
+faextender.Notifier.Start();
\ No newline at end of file
diff --git a/src/js/src/options.js b/src/js/src/options.js
index 588a6f6..8c98725 100644
--- a/src/js/src/options.js
+++ b/src/js/src/options.js
@@ -1,11 +1,12 @@
function loadOptions() {
- chrome.storage.sync.get(["openintabs_nodelay", "openintabs_unreverse", "hotkeys_enabled", "highlighter_keys"], optionsLoaded);
+ chrome.storage.sync.get(["openintabs_nodelay", "openintabs_unreverse", "hotkeys_enabled", "notifier_delay", "highlighter_keys"], optionsLoaded);
}
function optionsLoaded(obj) {
$("#delaytabs").prop("checked", !obj.openintabs_nodelay);
$("#reversetabs").prop("checked", !obj.openintabs_unreverse);
$("#hotkeys").prop("checked", obj.hotkeys_enabled);
+ $("#notifierdelay").val(obj.notifier_delay);
loadHighlight(obj.highlighter_keys);
}
@@ -22,6 +23,14 @@ function bindOptions() {
chrome.storage.sync.set( { "hotkeys_enabled": $(e.target).prop("checked") } );
});
+ jQuery("#notifierdelay").change(function(e) {
+ var textVal = $(e.target).val();
+ var val = parseInt(textVal);
+ if ((val == NaN) || (val < 1)) val = 0;
+
+ chrome.storage.sync.set( { "notifier_delay": val });
+ })
+
jQuery("#highlight_add").click(addNewHighlight);
jQuery("#reset").click(function() {
diff --git a/src/manifest.json b/src/manifest.json
index fa57738..86a443a 100644
--- a/src/manifest.json
+++ b/src/manifest.json
@@ -1,20 +1,32 @@
{
"name": "FurAffinity Extender",
- "version": "1.1.3",
+ "version": "1.2",
"manifest_version": 2,
"description": "FurAffinity Extender adds to the your browsing experience of FurAffinity.net by adding additional client-side features.",
"icons": {
"48": "icon48.png",
"128": "icon128.png"
},
+ "background": {
+ "scripts": ["js/lib/jquery-1.8.1.min.js", "js/src/notifier.js"]
+ },
"content_scripts": [{
"matches": ["http://*.furaffinity.net/*"],
"js": ["js/lib/jquery-1.8.1.min.js", "js/lib/jquery.hotkeys.js", "js/src/base.js", "js/src/hotkeys.js", "js/src/open_in_tabs.js", "js/src/story_in_gdocs.js", "js/src/highlighter.js"],
"run_at": "document_start"
}],
+ "browser_action": {
+ "default_icon": {
+ "19": "icon19.png",
+ "38": "icon38.png"
+ },
+ "default_title": "FurAffinity"
+ },
"homepage_url": "http://andrewneo.github.com/faextender-chrome/",
"options_page": "options.html",
"permissions": [
+ "*://*.furaffinity.net/*",
+ "alarms",
"storage"
]
}
\ No newline at end of file
diff --git a/src/options.html b/src/options.html
index 6066dbc..2faad10 100644
--- a/src/options.html
+++ b/src/options.html
@@ -20,6 +20,10 @@ FurAffinity Extender Settings
+
+
+ Notifier update check in minutes
+
Journal/submission highlighting