From 587ac6e531e008ad22428fc6c71bf636f744fd03 Mon Sep 17 00:00:00 2001 From: Wassup789 Date: Sat, 18 Nov 2017 01:18:08 -0800 Subject: [PATCH] v1.2.4.1 Release Fixed bug where the bell click event would remove the notification. Added syncWithYoutube background method call to manual refresh and upon enabling the bell --- CHANGELOG.md | 2 +- _locales/en/messages.json | 2 +- js/background.js | 3 +++ js/content_script.js | 47 ++++++++++++++++++++------------------- js/settings_edit.js | 6 +++++ manifest.json | 2 +- settings_edit.html | 2 +- 7 files changed, 37 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df1a8b..4ada3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ Changelog ===== -## v1.2.4.0 (2017-11-17) +## v1.2.4.1 (2017-11-17) * Added synchronization with YouTube's notification bell * New installs will have this feature automatically enabled * Current users must enable it from the settings diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 6409e12..04b9c22 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -85,7 +85,7 @@ }, "settings_editSettings_sync": { "description": "The label for the sync button", - "message": "Synchronize with YouTube" + "message": "Synchronize with YouTube's bell" }, "settings_vertSettings_viewChangelog": { "description": "The label for the view changelog button", diff --git a/js/background.js b/js/background.js index 9645a9d..b01bfb2 100644 --- a/js/background.js +++ b/js/background.js @@ -427,6 +427,9 @@ $(function(){ case "onSettingsOpen": sendResponse(resetChannelsHasNewVideo(true)); break; + case "syncWithYoutube": + sendResponse(syncWithYoutube()); + break; } }); diff --git a/js/content_script.js b/js/content_script.js index 03d5bf3..8b22703 100644 --- a/js/content_script.js +++ b/js/content_script.js @@ -31,7 +31,7 @@ window.onload = function(){ $(document).on("click", "#notification-button", function(){ if(!this.hasAttribute("data-channelId")) return; - var status = $(this).find("button").attr("aria-pressed") === "true", + var status = $(this).find("yt-icon-button").attr("aria-pressed") === "true", channelId = this.getAttribute("data-channelId"); if(status) @@ -89,7 +89,6 @@ $(function(){ } }); } - }); function onMessageResponse(type, id){ awaitingResponse.forEach(function(item, i) { @@ -193,7 +192,7 @@ function launchLegacy(){ return; } - var elem = ''; if(slashes.indexOf("subscription_manager") > -1 && $(".ytn-btn").length == 0){// If is on page: https://www.youtube.com/subscription_manager - var elems = $(elem).insertBefore(".yt-uix-overlay"); + var elems = $(elemContent).insertBefore(".yt-uix-overlay"); for(var i = 0; i < elems.length; i++){ var channelId = $($(".yt-uix-overlay")[i]).parent().children(".yt-uix-button").attr("data-channel-external-id"); $(elems[i]).attr("data-channelId", channelId); @@ -213,33 +212,35 @@ function launchLegacy(){ $(elems[response.index]).addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); }); } - }else if($(".ytn-btn").length < 1){// For everything else + }else{// For everything else $(".yt-uix-overlay").each(function(){ - var $this = $(this); - if( - $this.hasClass("channel-settings-overlay") || - $this.hasClass("featured-content-picker-overlay") || - $this.hasClass("settings-dialog-container") || - $(".about-metadata-container").find(this).length > 0 || - $this.parent().hasClass("channel-header-flagging-menu-container") || + var $this = $(this), + elem = null; + if($this.is(".channel-settings-overlay, .featured-content-picker-overlay, .settings-dialog-container") || + $this.parents(".about-metadata-container, .channel-header-flagging-menu-container").length > 0 || $this.parents(".primary-header-actions").find(".ytn-btn").length > 0) return; else{ + elem = $(elemContent); if($this.parents(".primary-header-actions").length > 0){ - var elem2 = elem.replace("float: initial", "float: right"); - $this.parents(".primary-header-actions").prepend(elem2); + elem[0].style.float = "right"; + $this.parents(".primary-header-actions").prepend(elem); }else - $(elem).insertBefore($this); + elem.insertBefore($this); } - }); - var channelId = $(".yt-uix-button.yt-uix-subscription-button").attr("data-channel-external-id"); - $(".ytn-btn").attr("data-channelId", channelId); - chrome.runtime.sendMessage({type: "doesYoutubeExist", id: channelId}, function(response){ - if(response.status) - $(".ytn-btn").removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); - else - $(".ytn-btn").addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); + if(elem == null) + return true; + + var channelId = $(".yt-uix-button.yt-uix-subscription-button").attr("data-channel-external-id"); + elem.attr("data-channelId", channelId); + chrome.runtime.sendMessage({type: "doesYoutubeExist", id: channelId}, function(response){ + if(response.status) + elem.removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); + else + elem.addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); + }); }); + } } \ No newline at end of file diff --git a/js/settings_edit.js b/js/settings_edit.js index 6fb163a..859034f 100644 --- a/js/settings_edit.js +++ b/js/settings_edit.js @@ -384,7 +384,10 @@ function registerListeners(){ }); $("#settings_refresh").on("click", function(){ + var settings = JSON.parse(localStorage.getItem("settings")); chrome.extension.sendMessage({type: "checkYoutubeBatch"}); + if(settings.sync.enabled) + chrome.extension.sendMessage({type: "syncWithYoutube"}); createToast(wyns.strings.updating); }); @@ -613,6 +616,9 @@ function configureSettings(){ localStorage.setItem("settings", JSON.stringify(settings)); checkAddBtn(); createToast(wyns.strings.saved); + + if(settings.sync.enabled) + chrome.extension.sendMessage({type: "syncWithYoutube"}); })[0].active = settings.sync.enabled; checkAddBtn(); diff --git a/manifest.json b/manifest.json index 56ab9d3..de26b53 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ }, "name": "__MSG_appName__", "description": "__MSG_appDesc__", - "version": "1.2.4.0", + "version": "1.2.4.1", "permissions": [ "notifications", "unlimitedStorage", diff --git a/settings_edit.html b/settings_edit.html index 9780452..de55895 100644 --- a/settings_edit.html +++ b/settings_edit.html @@ -337,7 +337,7 @@
-
v1.2.4.0
+
v1.2.4.1
  • Added synchronization with YouTube's notification bell