Skip to content

Commit

Permalink
Merge pull request #1396 from hboyd2003/master
Browse files Browse the repository at this point in the history
Fixed Issue #1395
  • Loading branch information
ImprovedTube committed Sep 27, 2022
2 parents f152fbf + c5eae71 commit f1090c9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions youtube-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1512,14 +1512,24 @@ ImprovedTube.howLongAgoTheVideoWasUploaded = function () {

ImprovedTube.channelVideosCount = function () {
if (this.storage.channel_videos_count === true && this.elements.yt_channel_link) {
var xhr = new XMLHttpRequest(),
key = this.storage['google-api-key'] || ImprovedTube.defaultApiKey,
var key = this.storage['google-api-key'] || ImprovedTube.defaultApiKey;
if (this.elements.yt_channel_link.href.indexOf('/channel/') == -1) {
var xhr = new XMLHttpRequest(),
id = this.getParam(location.href.slice(location.href.indexOf('?') + 1), 'v');

xhr.open('GET', 'https://www.googleapis.com/youtube/v3/videos?part=snippet&id=' + id + '&key=' + key, false);
xhr.send();
var response = JSON.parse(xhr.responseText);
id = response.items[0].snippet.channelId;
} else {
id = this.elements.yt_channel_link.href.slice(this.elements.yt_channel_link.href.indexOf('/channel/') + '/channel/'.length);

if (id.indexOf('/') !== -1) {
id = id.match(/.+?(?=\/)/)[0];
if (id.indexOf('/') !== -1) {
id = id.match(/.+?(?=\/)/)[0];
}
}

xhr = new XMLHttpRequest();

xhr.addEventListener('load', function () {
var response = JSON.parse(this.responseText),
parent = document.querySelector('#meta ytd-channel-name + yt-formatted-string'),
Expand Down

0 comments on commit f1090c9

Please sign in to comment.