|
1 | 1 | // ==UserScript== |
2 | | -// @version 1.7.9 |
| 2 | +// @version 1.8.0 |
3 | 3 | // @name YouTube + |
4 | 4 | // @namespace https://github.com/ParticleCore |
5 | 5 | // @description YouTube with more freedom |
| 6 | +// @compatible chrome |
| 7 | +// @compatible firefox |
6 | 8 | // @icon https://raw.githubusercontent.com/ParticleCore/Particle/gh-pages/images/YT%2Bicon.png |
7 | 9 | // @match *://www.youtube.com/* |
8 | 10 | // @exclude *://www.youtube.com/tv* |
|
594 | 596 | if (temp !== "player-api" && temp !== "upsell-video") { |
595 | 597 | return original.apply(this, arguments); |
596 | 598 | } |
597 | | - /*b = */modArgs(b); |
| 599 | + modArgs(b); |
598 | 600 | temp = original.apply(this, arguments); |
599 | 601 | player = document.getElementById("movie_player"); |
600 | 602 | if (player) { |
|
613 | 615 | function modAutoplayFullscreen(original) { |
614 | 616 | return function () { |
615 | 617 | var has_ended, next_button, next_clicked; |
| 618 | + if (!document.mozFullScreenElement && !document.webkitFullscreenElement) { |
| 619 | + return original.apply(this, arguments); |
| 620 | + } |
616 | 621 | has_ended = api && api.getCurrentTime && Math.round(api.getCurrentTime()) >= Math.floor(api.getDuration()); |
617 | 622 | next_clicked = document.activeElement.classList.contains("ytp-button-next") || document.activeElement.classList.contains("ytp-next-button"); |
618 | 623 | if (!user_settings.plApl && !next_clicked && has_ended) { |
|
634 | 639 | } |
635 | 640 | function modPlayerCreate(original) { |
636 | 641 | return function (a, b) { |
637 | | - var i, temp, player; |
| 642 | + var temp, player; |
638 | 643 | temp = a.id || a; |
639 | 644 | if (temp !== "player-api" && temp !== "upsell-video") { |
640 | 645 | return original.apply(this, arguments); |
641 | 646 | } |
642 | | - /*b = */modArgs(b); |
| 647 | + modArgs(b); |
643 | 648 | if (a.id === "upsell-video") { |
644 | 649 | original.apply(this, arguments); |
645 | 650 | } else if (typeof a === "object") { |
646 | 651 | player_instance = original.apply(this, arguments); |
647 | | - temp = Object.keys(player_instance); |
648 | | - i = temp.length; |
649 | | - while (i--) { |
650 | | - if (typeof player_instance[temp[i]] === "object" && player_instance[temp[i]] && player_instance[temp[i]].hasNext) { |
651 | | - player_instance[temp[i]].hasNext = modAutoplayFullscreen(player_instance[temp[i]].hasNext); |
652 | | - break; |
653 | | - } |
654 | | - } |
655 | 652 | player = document.getElementById("movie_player"); |
656 | 653 | if (user_settings.VID_PLR_FIT) { |
657 | 654 | resizePlayer(); |
|
722 | 719 | window.yt.player.Application.create = modPlayerCreate(window.yt.player.Application.create); |
723 | 720 | if (window._yt_player) { |
724 | 721 | temp = Object.keys(window._yt_player); |
| 722 | + for (i = 0; i < temp.length; i++) { |
| 723 | + if (typeof window._yt_player[temp[i]] === "function" && window._yt_player[temp[i]].prototype && window._yt_player[temp[i]].prototype.hasNext) { |
| 724 | + window._yt_player[temp[i]].prototype.hasNext = modAutoplayFullscreen(window._yt_player[temp[i]].prototype.hasNext); |
| 725 | + break; |
| 726 | + } |
| 727 | + } |
725 | 728 | for (i = 0; i < temp.length; i++) { |
726 | 729 | if (typeof window._yt_player[temp[i]] === "function" && window._yt_player[temp[i]].toString().match(/this\.adaptiveFormats/)) { |
727 | 730 | key = temp[i]; |
|
1991 | 1994 | function infiniteScroll() { |
1992 | 1995 | var observer, loadMore; |
1993 | 1996 | loadMore = document.querySelector(".load-more-button"); |
1994 | | - if (loadMore && user_settings.GEN_INF_SCRL) { |
| 1997 | + if (window.location.pathname !== "/watch" && loadMore && user_settings.GEN_INF_SCRL) { |
1995 | 1998 | if (!loadMore.classList.contains("infiniteScroll")) { |
1996 | 1999 | loadMore.classList.add("infiniteScroll"); |
1997 | 2000 | observer = new MutationObserver(infiniteScroll); |
|
2087 | 2090 | } |
2088 | 2091 | function isMaterial() { |
2089 | 2092 | var temp; |
2090 | | - temp = document.querySelector("ytd-app"); |
| 2093 | + temp = document.querySelector("ytd-app, [src*='polymer'],[href*='polymer']"); |
2091 | 2094 | if (temp && !document.getElementById("material-notice")) { |
2092 | 2095 | temp = document.createElement("template"); |
2093 | 2096 | temp.innerHTML = // |
2094 | | - `<div id='material-notice' style='border-radius:2px;color:#FFF;padding:10px;background-color:#09F;box-shadow:0 0 3px rgba(0,0,0,.5);font-size:12px;position:fixed;bottom:20px;right:20px;z-index:99999'> |
| 2097 | + `<div id='material-notice' style='border-radius:2px;color:#FFF;padding:10px;background-color:#09F;box-shadow:0 0 3px rgba(0,0,0,.5);font-size:12px;position:fixed;bottom:20px;right:50px;z-index:99999'> |
2095 | 2098 | YouTube Plus is not compatible with the YouTube beta Material Layout<br> |
2096 | | - The development of YouTube Plus might end when this layout is officially launched, <a href='https://github.com/ParticleCore/Particle/issues/448' target='_blank' style='color:#FFF;font-weight:bold;'>click here</a> to read the announcement<br> |
| 2099 | + <a href='https://github.com/ParticleCore/Particle/wiki/Restore-classic-YouTube' target='_blank' style='color:#FFF;font-weight:bold;'>Click here</a> for instructions to restore classic YouTube and continue using YT+<br> |
| 2100 | + The development of YT+ might end when this layout is launched permanently,<br> |
| 2101 | + <a href='https://github.com/ParticleCore/Particle/issues/448' target='_blank' style='color:#FFF;font-weight:bold;'>click here</a> to read the announcement<br> |
2097 | 2102 | To keep using the current layout without this message please disable YT+ |
2098 | 2103 | </div>`; |
2099 | 2104 | document.documentElement.appendChild(temp.content.firstChild); |
|
2336 | 2341 | holder = document.createElement("link"); |
2337 | 2342 | holder.rel = "stylesheet"; |
2338 | 2343 | holder.type = "text/css"; |
2339 | | - holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.7.9"; |
| 2344 | + holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.8.0"; |
2340 | 2345 | document.documentElement.appendChild(holder); |
2341 | 2346 | } |
2342 | 2347 | holder = document.createElement("script"); |
|
0 commit comments