Skip to content
This repository was archived by the owner on Mar 23, 2018. It is now read-only.

Commit d28a2d9

Browse files
committed
1.8.4
- Fixed #435 - Fixed #478 - Added Vietnamese locale
1 parent 9e56e07 commit d28a2d9

6 files changed

Lines changed: 70 additions & 18 deletions

File tree

bin/update.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"addons": {
33
"unlisted-particle@particlecore.github.io": {
44
"updates": [{
5-
"version": "1.8.3",
5+
"version": "1.8.4",
66
"update_link": "https://github.com/ParticleCore/Particle/raw/master/dist/YouTubePlus.xpi",
77
"applications": {
88
"gecko": {

dist/YouTubePlus.xpi

2.32 KB
Binary file not shown.

src/Userscript/YouTubePlus.user.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 1.8.3
2+
// @version 1.8.4
33
// @name YouTube +
44
// @namespace https://github.com/ParticleCore
55
// @description YouTube with more freedom
@@ -950,11 +950,11 @@
950950
}
951951
}
952952
function getThumb() {
953-
var args, base, thumb_url;
954-
args = window.ytplayer.config.args;
955-
base = (args.iurl_webp && "_webp") || "";
956-
thumb_url = args["iurlmaxres" + base] || args["iurlsd" + base] || args["iurl" + base];
957-
window.open(thumb_url);
953+
if (getThumb.thumbnail_url) {
954+
window.open(getThumb.thumbnail_url);
955+
} else if (window.ytplayer && window.ytplayer.config && window.ytplayer.config.args && window.ytplayer.config.args.thumbnail_url) {
956+
window.open(window.ytplayer.config.args.thumbnail_url);
957+
}
958958
}
959959
function hideScreenshot(event) {
960960
if (event.target.id === "close-screenshot") {
@@ -1129,7 +1129,7 @@
11291129
}
11301130
}
11311131
function advancedOptions() {
1132-
var header, cnslBtn, cnslCont;
1132+
var header, cnslBtn, cnslCont, thumbnail_url;
11331133
header = document.getElementById("watch-header");
11341134
cnslBtn = document.getElementById("console-button");
11351135
advancedOptions.controls = document.getElementById("player-console");
@@ -1172,6 +1172,11 @@
11721172
if (user_settings.VID_PLR_ATPL) {
11731173
advancedOptions.controls.content.querySelector("#autoplay-button").classList.add("active");
11741174
}
1175+
thumbnail_url = document.querySelector("link[itemprop='thumbnailUrl'], span[itemprop='thumbnail'] link[itemprop='url']");
1176+
thumbnail_url = thumbnail_url && thumbnail_url.getAttribute("href");
1177+
if (thumbnail_url) {
1178+
getThumb.thumbnail_url = thumbnail_url;
1179+
}
11751180
advancedOptions.controls = setLocale(advancedOptions.controls.content).firstChild;
11761181
cnslCont.appendChild(advancedOptions.controls);
11771182
hookButtons();
@@ -1942,6 +1947,24 @@
19421947
return temp;
19431948
};
19441949
}
1950+
function checkDomParser(original) {
1951+
return function() {
1952+
var i, fps, result, streams;
1953+
if (user_settings.VID_PLR_HFR) {
1954+
result = original.apply(this, arguments);
1955+
streams = result.getElementsByTagName("Representation");
1956+
i = streams.length;
1957+
while (i--) {
1958+
fps = streams[i].getAttribute("frameRate");
1959+
if (fps > 30) {
1960+
streams[i].remove();
1961+
}
1962+
}
1963+
return result;
1964+
}
1965+
return original.apply(this, arguments);
1966+
};
1967+
}
19451968
function generalChanges() {
19461969
var logo, checkbox, autoplaybar, description;
19471970
autoplaybar = document.querySelector(".autoplay-bar");
@@ -2292,6 +2315,7 @@
22922315
document.addEventListener("spfrequest", request);
22932316
document.addEventListener("readystatechange", main, true);
22942317
XMLHttpRequest.prototype.open = checkXHR(XMLHttpRequest.prototype.open);
2318+
DOMParser.prototype.parseFromString = checkDomParser(DOMParser.prototype.parseFromString);
22952319
window.onYouTubePlayerReady = shareApi(window.onYouTubePlayerReady);
22962320
window.matchMedia = modMatchMedia(window.matchMedia);
22972321
main();
@@ -2341,7 +2365,7 @@
23412365
holder = document.createElement("link");
23422366
holder.rel = "stylesheet";
23432367
holder.type = "text/css";
2344-
holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.8.3";
2368+
holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.8.4";
23452369
document.documentElement.appendChild(holder);
23462370
}
23472371
holder = document.createElement("script");

src/Webextension/JS/YouTubePlus.user.js

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// ==UserScript==
2-
// @version 1.8.3
2+
// @version 1.8.4
33
// @name YouTube +
44
// @namespace https://github.com/ParticleCore
55
// @description YouTube with more freedom
@@ -950,11 +950,11 @@
950950
}
951951
}
952952
function getThumb() {
953-
var args, base, thumb_url;
954-
args = window.ytplayer.config.args;
955-
base = (args.iurl_webp && "_webp") || "";
956-
thumb_url = args["iurlmaxres" + base] || args["iurlsd" + base] || args["iurl" + base];
957-
window.open(thumb_url);
953+
if (getThumb.thumbnail_url) {
954+
window.open(getThumb.thumbnail_url);
955+
} else if (window.ytplayer && window.ytplayer.config && window.ytplayer.config.args && window.ytplayer.config.args.thumbnail_url) {
956+
window.open(window.ytplayer.config.args.thumbnail_url);
957+
}
958958
}
959959
function hideScreenshot(event) {
960960
if (event.target.id === "close-screenshot") {
@@ -1129,7 +1129,7 @@
11291129
}
11301130
}
11311131
function advancedOptions() {
1132-
var header, cnslBtn, cnslCont;
1132+
var header, cnslBtn, cnslCont, thumbnail_url;
11331133
header = document.getElementById("watch-header");
11341134
cnslBtn = document.getElementById("console-button");
11351135
advancedOptions.controls = document.getElementById("player-console");
@@ -1172,6 +1172,11 @@
11721172
if (user_settings.VID_PLR_ATPL) {
11731173
advancedOptions.controls.content.querySelector("#autoplay-button").classList.add("active");
11741174
}
1175+
thumbnail_url = document.querySelector("link[itemprop='thumbnailUrl'], span[itemprop='thumbnail'] link[itemprop='url']");
1176+
thumbnail_url = thumbnail_url && thumbnail_url.getAttribute("href");
1177+
if (thumbnail_url) {
1178+
getThumb.thumbnail_url = thumbnail_url;
1179+
}
11751180
advancedOptions.controls = setLocale(advancedOptions.controls.content).firstChild;
11761181
cnslCont.appendChild(advancedOptions.controls);
11771182
hookButtons();
@@ -1942,6 +1947,24 @@
19421947
return temp;
19431948
};
19441949
}
1950+
function checkDomParser(original) {
1951+
return function() {
1952+
var i, fps, result, streams;
1953+
if (user_settings.VID_PLR_HFR) {
1954+
result = original.apply(this, arguments);
1955+
streams = result.getElementsByTagName("Representation");
1956+
i = streams.length;
1957+
while (i--) {
1958+
fps = streams[i].getAttribute("frameRate");
1959+
if (fps > 30) {
1960+
streams[i].remove();
1961+
}
1962+
}
1963+
return result;
1964+
}
1965+
return original.apply(this, arguments);
1966+
};
1967+
}
19451968
function generalChanges() {
19461969
var logo, checkbox, autoplaybar, description;
19471970
autoplaybar = document.querySelector(".autoplay-bar");
@@ -2292,6 +2315,7 @@
22922315
document.addEventListener("spfrequest", request);
22932316
document.addEventListener("readystatechange", main, true);
22942317
XMLHttpRequest.prototype.open = checkXHR(XMLHttpRequest.prototype.open);
2318+
DOMParser.prototype.parseFromString = checkDomParser(DOMParser.prototype.parseFromString);
22952319
window.onYouTubePlayerReady = shareApi(window.onYouTubePlayerReady);
22962320
window.matchMedia = modMatchMedia(window.matchMedia);
22972321
main();
@@ -2341,7 +2365,7 @@
23412365
holder = document.createElement("link");
23422366
holder.rel = "stylesheet";
23432367
holder.type = "text/css";
2344-
holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.8.3";
2368+
holder.href = "https://particlecore.github.io/Particle/stylesheets/YouTubePlus.css?v=1.8.4";
23452369
document.documentElement.appendChild(holder);
23462370
}
23472371
holder = document.createElement("script");

0 commit comments

Comments
 (0)