From c97b5a55e9902a681e207368022f3823993a5448 Mon Sep 17 00:00:00 2001 From: Wassup789 Date: Thu, 31 Aug 2017 18:47:28 -0700 Subject: [PATCH] v1.2.3.0 Release Added support for the new YouTube layout and resources --- .idea/deployment.xml | 14 ++ CHANGELOG.md | 4 + YouTube-Notifications.iml | 1 - css/settings.css | 3 +- img/yt_logo.png | Bin 9450 -> 0 bytes img/yt_logo.svg | 43 +++++ img/yt_logo_alt.svg | 44 ++++++ js/content_script.js | 250 ++++++++++++++++++++---------- manifest.json | 2 +- pages/edit-notification.css | 3 +- pages/edit-notification_edit.html | 2 +- pages/first-launch.css | 2 +- pages/first-launch.html | 4 +- pages/first-launch.js | 3 +- pages/upload-file.css | 3 +- pages/upload-file_edit.html | 2 +- settings_edit.html | 8 +- 17 files changed, 291 insertions(+), 97 deletions(-) create mode 100644 .idea/deployment.xml delete mode 100644 img/yt_logo.png create mode 100644 img/yt_logo.svg create mode 100644 img/yt_logo_alt.svg diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..c3bceb6 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f04f64..e4d1204 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Changelog ===== +## v1.2.3.0 (08-31-2017) + * Added support and updated resources for the new YouTube layout + * Added pt_BR translations (Thanks @frnogueira) + ## v1.2.2.1 (04-10-2017) * Fixed a bug where the data would not update because of a YouTube Data API error * Changed default sort order to be by video upload date diff --git a/YouTube-Notifications.iml b/YouTube-Notifications.iml index 5d6d2a9..109ecab 100644 --- a/YouTube-Notifications.iml +++ b/YouTube-Notifications.iml @@ -5,7 +5,6 @@ - \ No newline at end of file diff --git a/css/settings.css b/css/settings.css index db25de2..44fdf13 100644 --- a/css/settings.css +++ b/css/settings.css @@ -49,7 +49,8 @@ paper-toolbar paper-tabs { align-self: flex-end; } #header_img { - height: 32px; + height: 24px; + margin-top: -4px; } #page-latestUploads #main_card, #page-editSettings #main_card2 { diff --git a/img/yt_logo.png b/img/yt_logo.png deleted file mode 100644 index b5b336073fb831ad9e02dbd7b8bf6b0c1f1fce6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9450 zcmZvBbwE_#*7iY=ln^OFkdP25NgWtkx)HFvgllOik`mJs0{}p(tR$}k05}-z_d!B@ z?B|z^c`odU$VJKMB><4zx;k)xl#g@(K&<&(PEJe9&e`4hrJb`2v$C8Vvx}Rv&GQ%5 z0Pt!Op=+zByGjE-oZXjIg$KS@b=ILKWY&?545W(X;ASDBP=T{#Oi*jL+yaE%HeR5#MtGC96(wDClHaup$nwr0T$g>&;>w?7qH+ASRMib z5l6`|9Khr~3pGx9EWmur8ZHmmi33G_Pa~cHh5`VUjcVItV4N2aP&Tkp0?Mj^=3WYt z&j8^KKtLP*`aXaM11!F=vAqI9lL0D)T?2`o2PG6}ZY)#DpCxMUJ$@2oLdfe%U|_(< z#MP@z`+!Q+@|tCeG~ZY6oB}rA^kvvdh5l!uBhq+2H)evA@LG;laRd6M9SF2hj&lV7bNPFG zdR^sGorC}&pB}_rCd07bLdVmLf2Za8bPLIug=nbky|%Bi6tcw60`It4+%F22<$BXo z#>j2KKP=5C+^lW)CfJbl7yj3@fwdh7+2YuPoBHX(01FJri7anEMlV&1OJTF;hOC}j5Lp4K5`cp$_SU+j8Abr6ZuTz3oL;nxvL< zdnodDr=Eb=!}TO|GI_GIz9DxNw=Z>U7jc400!IP^H@{wfK~BMJ0g3*eez#sszPYYn ziGse6?m|A%@P|VE0)*DOE`zRZzIa|(fo-0%o>Z2<(Rnz&QL9?3rd*bGItsE--@!~` zb-Vl(4~qk7;Tw-2kv0xg&xEfhcU{ssV_hV;AV1@=oREr;LAlP}dmAZ&g(TObkM0^o zXs+DEJ^zSVs_pyp_Zf18)oLDEn>rMHNc><}s8pz3sJPxBTC$mo$Z2>|XLK4w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c6A{6IP-5V)pZP$2?8U#Qi$#7;3mNq$LQ+ z%%z%BGZLM-pL@2*%FlUQXq%T~Ria9ysP33q^$o4jG69vjl&JJ+SdEP9R{imcG~eDp z(8pbz)s-R-4VSJje$O@hc87;LroO$l@;F!=F9|@$=OUkaU02-pDxm%NXsi?=X|<>x z2$^!Mbn~CgUayZDKgh~@jtB9QUWr@3F`s@&YX4EfSrYWFkj)cZbmmygp8)|sv?+f3 zkph<3bh#G(@Sybav~HkEv}NR$)h98&)U-?p7DD^F1TlP+3e=am?$=fSxyJ#*$3EpP zI@@C$@)X^qKJxu=;KKAE^ZfC3pK&^UPa(%Mhq~geMxj$J!3wiaRgK4EVs$CJJNd=v z3v`n4s~u~PTpyMJy>qPG)}Hnj)q0-%Xq~w072tq>kbE4REm9B-P^J`% zOrmHxvkE9ViNS&aEQpY$w^(^Fl#C>RVK90<)Q$r7ruRC)qn$&`As;hs1)>AWq=T4} zD8SIPtPmWaRd~gZXn+&55qA2L7-(j$Usizk`hJlz$jrn6LIg-P;Wntm6+57rqUa50 z+q-EK_eX$5ASLz}TN~`Jw5>QmPle=Srf?|TEf^-`DuVP_?gm~K{JoY7(}ZXOKsYWt zm%S}({BY?LIcA9p2*jr=z6Dj@5&iU;`dfxxmZ!TxO%V@}t&kk= zRCy&^w0!PY^W*f??d{^4r<>6xEB8%AI%sQGQb&l?01M zSAz<{bpSl*6L6QIfg*Ss2gtuA`%WBS_K;NyuCL}d@Ng$vEcfDpRgAzs)Zu*VL^ z+BVq|RUlfp>f_kX@?N8y>ySrK84*iJ0(N$Q?7f%ex_awVV?sNN{B1XLJ + + + + + + + + + + + + + + + + + + + diff --git a/img/yt_logo_alt.svg b/img/yt_logo_alt.svg new file mode 100644 index 0000000..8d49285 --- /dev/null +++ b/img/yt_logo_alt.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/js/content_script.js b/js/content_script.js index 48185be..686ef9b 100644 --- a/js/content_script.js +++ b/js/content_script.js @@ -7,91 +7,177 @@ var awaitingResponse = []; * @returns {string} The localized string */ function getString(name) { - return chrome.i18n.getMessage("contentScript_" + name); + return chrome.i18n.getMessage("contentScript_" + name); } $(function(){ - chrome.runtime.sendMessage({type: "showAddButton"}, function(response){ - if(response){ - launch(); - setInterval(function(){ - launch(); - }, 1000); - } - }); + chrome.runtime.sendMessage({type: "showAddButton"}, function(response){ + if(response){ + if(!(document.querySelector("ytd-app") !== null)) + launchLegacy(); + else + launch(); + setInterval(function(){ + if(!(document.querySelector("ytd-app") !== null)) + launchLegacy(); + else + launch(); + }, 1000); + } + }); - chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ - switch (request.type) { - case "contentScript_response": - onMessageResponse(request.responseType, request.id); - break; - } - }); + chrome.runtime.onMessage.addListener(function(request, sender, sendResponse){ + switch (request.type) { + case "contentScript_response": + onMessageResponse(request.responseType, request.id); + break; + } + }); - $(document).on("click", "#ytn-btn, .ytn-btn", function(){ - var elem = $(this), - channelId = elem.attr("data-channelId"); + //Legacy + if(!(document.querySelector("ytd-app") !== null)){ + $(document).on("click", "#ytn-btn, .ytn-btn", function(){ + var elem = $(this), + channelId = elem.attr("data-channelId"); + + if(elem.hasClass("yt-uix-button-subscribe-branded")){// Add channel + awaitingResponse.push({ + id: channelId, + elem: elem + }); + chrome.runtime.sendMessage({type: "addYoutubeChannel", contentScript: true, name: channelId, refresh: true}); + }else if(elem.hasClass("yt-uix-button-subscribed-branded")){// Remove channel + awaitingResponse.push({ + id: channelId, + elem: elem + }); + chrome.runtime.sendMessage({type: "removeYoutube", num: 1, contentScript: true, name: channelId, refresh: true}); + } + }); + }else{ + $(document).on("click", ".ytn-btn", function(){ + var elem = $(this), + channelId = elem.attr("data-channelId"); + + awaitingResponse.push({ + id: channelId, + elem: elem + }); + if(!elem.attr("subscribed")){// Add channel + chrome.runtime.sendMessage({type: "addYoutubeChannel", contentScript: true, name: channelId, refresh: true}); + }else{// Remove channel + chrome.runtime.sendMessage({type: "removeYoutube", num: 1, contentScript: true, name: channelId, refresh: true}); + } + }); + } - if(elem.hasClass("yt-uix-button-subscribe-branded")){// Add channel - awaitingResponse.push({ - id: channelId, - elem: elem - }); - chrome.runtime.sendMessage({type: "addYoutubeChannel", contentScript: true, name: channelId, refresh: true}); - }else if(elem.hasClass("yt-uix-button-subscribed-branded")){// Remove channel - awaitingResponse.push({ - id: channelId, - elem: elem - }); - chrome.runtime.sendMessage({type: "removeYoutube", num: 1, contentScript: true, name: channelId, refresh: true}); - } - }); }); function onMessageResponse(type, id){ - awaitingResponse.forEach(function(item, i) { - if(item.id == id){ - if(type) - item.elem.removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); - else - item.elem.addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); - awaitingResponse.pop(i); - } - }); + awaitingResponse.forEach(function(item, i) { + if(item.id === id){ + if(document.querySelector("ytd-app") === null) { + if (type) + item.elem.removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); + else + item.elem.addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); + }else{ + if (type) { + item.elem.find("span").text(getString("removeChannel").replace("YouTube Notifications", "YTN")); + item.elem.attr("subscribed", true); + }else{ + item.elem.find("span").text(getString("addChannel").replace("YouTube Notifications", "YTN")); + item.elem.removeAttr("subscribed"); + } + } + awaitingResponse.pop(i); + } + }); } + function launch(){ - var slashes = window.location.href.split("/"); - if(slashes.indexOf("user") < 0 && slashes.indexOf("channel") < 0 && slashes.indexOf("subscription_manager") < 0 && slashes.pop().split("?").shift() != "watch"){ - 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"); - 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); - chrome.runtime.sendMessage({type: "doesYoutubeExist", id: channelId, index: i}, function(response){ - if(response.status) - $(elems[response.index]).removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); - else - $(elems[response.index]).addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); - }); - } - }else if($(".ytn-btn").length < 1){// For everything else + var code = 'var subscribeButton = document.querySelectorAll("#subscribe-button");\ + subscribeButton.forEach(function(e){\ + if(e.querySelector(":scope > paper-button") !== null)\ + return;\ + e.style.display = "flex";\ + e.style.flexDirection = "row";\ + e.style.alignItems = "center";\ +\ + var idElem = e.querySelector("[data-channel-external-id]");\ + if(!idElem) return;\ + var id = idElem.getAttribute("data-channel-external-id");\ +\ + var paperButton = document.createElement("paper-button");\ + paperButton.classList = "ytn-btn ytd-subscribe-button-renderer";\ + paperButton.setAttribute("data-channelId", id);\ + paperButton.setAttribute("init", false);\ + paperButton.style.display = "none";\ +\ + var span = document.createElement("span");\ + paperButton.appendChild(span);\ +\ + Polymer.dom(e).appendChild(paperButton);\ + });'; + if(document.querySelector("[ytn-script]") !== null) + document.querySelector("[ytn-script]").remove(); + + var script = document.createElement("script"); + script.setAttribute("ytn-script", true); + script.innerHTML = code; + document.head.appendChild(script); + + document.querySelectorAll(".ytn-btn[init='false']").forEach(function (e) { + var channelId = e.getAttribute("data-channelId"); + + chrome.runtime.sendMessage({type: "doesYoutubeExist", id: channelId, index: -1}, function (response) { + if (response.status){ + e.querySelector("span").innerHTML = getString("removeChannel").replace("YouTube Notifications", "YTN"); + e.setAttribute("subscribed", true); + }else{ + e.querySelector("span").innerHTML = getString("addChannel").replace("YouTube Notifications", "YTN"); + e.removeAttribute("subscribed"); + } + e.style.display = "flex"; + + e.removeAttribute("init"); + }); + }); +} + +function launchLegacy(){ + var slashes = window.location.href.split("/"); + if(slashes.indexOf("user") < 0 && slashes.indexOf("channel") < 0 && slashes.indexOf("subscription_manager") < 0 && slashes.pop().split("?").shift() != "watch"){ + 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"); + 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); + chrome.runtime.sendMessage({type: "doesYoutubeExist", id: channelId, index: i}, function(response){ + if(response.status) + $(elems[response.index]).removeClass("yt-uix-button-subscribe-branded").addClass("yt-uix-button-subscribed-branded"); + else + $(elems[response.index]).addClass("yt-uix-button-subscribe-branded").removeClass("yt-uix-button-subscribed-branded"); + }); + } + }else if($(".ytn-btn").length < 1){// For everything else $(".yt-uix-overlay").each(function(){ 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")) + $(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")) return; else{ if($(".primary-header-actions").find(this).length > 0){ @@ -102,13 +188,13 @@ function launch(){ } }); - 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"); - }); - } + 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"); + }); + } } diff --git a/manifest.json b/manifest.json index 58a58e1..d624f0c 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ }, "name": "__MSG_appName__", "description": "__MSG_appDesc__", - "version": "1.2.2.0", + "version": "1.2.3.0", "permissions": [ "notifications", "unlimitedStorage", diff --git a/pages/edit-notification.css b/pages/edit-notification.css index e930f8e..95f839c 100644 --- a/pages/edit-notification.css +++ b/pages/edit-notification.css @@ -106,7 +106,8 @@ a, .link{ } #header_img { - height: 32px; + height: 24px; + margin-top: -4px; } #notification { diff --git a/pages/edit-notification_edit.html b/pages/edit-notification_edit.html index 88dc209..2c42eb5 100644 --- a/pages/edit-notification_edit.html +++ b/pages/edit-notification_edit.html @@ -70,7 +70,7 @@ - + Notifications -
diff --git a/pages/first-launch.css b/pages/first-launch.css index 890a799..d0645a9 100644 --- a/pages/first-launch.css +++ b/pages/first-launch.css @@ -48,7 +48,7 @@ a:hover { font-size: 62px; } #header-title img { - height: 100px; + height: 50px; } #credits { float: right; diff --git a/pages/first-launch.html b/pages/first-launch.html index 398fbe8..271b92d 100644 --- a/pages/first-launch.html +++ b/pages/first-launch.html @@ -12,7 +12,7 @@