Skip to content

Commit

Permalink
transcript always. done #1545 + description finish re: #1590
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube committed Mar 20, 2023
1 parent d495869 commit b467b28
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
19 changes: 15 additions & 4 deletions content-scripts/website-context/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ document.addEventListener('it-message-from-extension', function () {
ImprovedTube.storage = message.storage;

ImprovedTube.init();
} else if (message.action === 'storage-changed') {
} else if (message.action === 'storage-changed') {
var camelized_key = message.camelizedKey;

ImprovedTube.storage[message.key] = message.value;
Expand All @@ -136,11 +136,22 @@ document.addEventListener('it-message-from-extension', function () {
} else if (camelized_key === 'theme') {
ImprovedTube.myColors();
ImprovedTube.setTheme();
}
else if (camelized_key === 'description') {
} else if (camelized_key === 'description') {
if (ImprovedTube.storage.description === "expanded" || ImprovedTube.storage.description === "classic_expanded" )
{document.querySelector("#more").click() || document.querySelector("#expand").click() ;}
if (ImprovedTube.storage.description === "normal" || ImprovedTube.storage.description === "classic" )
{document.querySelector("#less").click() || document.querySelector("#collapse").click() ;}
}
}
else if (camelized_key === 'transcript') {
if (ImprovedTube.storage.transcript === true){
document.querySelector('#below svg path[d^="M7.5,12c0,0.83-0.67,1.5-1.5"]').closest("button").click();
setTimeout(function(){
try{document.querySelector('tp-yt-iron-dropdown svg path[d^="M5,11h2v2H5V11z M15,15H5v2h10V15z"]').closest("tp-yt-paper-item").click();}
catch(e){console.log(e); setTimeout(function(){
try{document.querySelector('tp-yt-iron-dropdown svg path[d^="M5,11h2v2H5V11z M15,15H5v2h10V15z"]').closest("tp-yt-paper-item").click();}
catch{}},200);}},1)
} if (ImprovedTube.storage.transcript === false){document.querySelector('*[target-id*=transcript] #visibility-button button').click();}
}
if (ImprovedTube[camelized_key]) {
ImprovedTube[camelized_key]();
}
Expand Down
18 changes: 12 additions & 6 deletions content-scripts/website-context/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,20 @@ ImprovedTube.ytElementsHandler = function (node) {
if (document.documentElement.dataset.pageType === 'video'){
setTimeout(function () {
ImprovedTube.description(node);
}, 750);
}, 300);
}
//old
}else if (name === 'TP-YT-PAPER-BUTTON') {
if (document.documentElement.dataset.pageType === 'video' && id === 'more' && node.classList.contains('ytd-expander') || (node.parentNode.parentNode !== null && node.parentNode.parentNode.id === 'container')) {
}else if (id === 'meta') {
if (document.documentElement.dataset.pageType === 'video') {
setTimeout(function () {
ImprovedTube.description(node);
}, 750);
ImprovedTube.description(node.querySelector('#more'));
}, 300);
}
}
else if (id === 'below') {
if (document.documentElement.dataset.pageType === 'video') {
setTimeout(function () {
ImprovedTube.transcript(node);
}, 400);
}
}
};
Expand Down
22 changes: 18 additions & 4 deletions content-scripts/website-context/youtube-features/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,21 @@ ImprovedTube.commentsSidebarPosition=()=>{ if(ImprovedTube.storage.comments_side
/*------------------------------------------------------------------------------
4.2.2 SIDEBAR
------------------------------------------------------------------------------*/
/*----------------------------------------------------------------
# TRANSCRIPT
--------------------------------------------------------------*/

ImprovedTube.transcript = function (el){
if (ImprovedTube.storage.transcript === true){
try{el.querySelector('svg path[d^="M7.5,12c0,0.83-0.67,1.5-1.5"]').closest("button").click();}
catch(e){console.log(e);
setTimeout(function(){try{el.querySelector('svg path[d^="M7.5,12c0,0.83-0.67,1.5-1.5"]').closest("button").click();}
catch{}},800)};
setTimeout(function(){try{document.querySelector('tp-yt-iron-dropdown svg path[d^="M5,11h2v2H5V11z M15,15H5v2h10V15z"]').closest("tp-yt-paper-item").click();}
catch{setTimeout(function(){try{document.querySelector('tp-yt-iron-dropdown svg path[d^="M5,11h2v2H5V11z M15,15H5v2h10V15z"]').closest("tp-yt-paper-item").click();}
catch{el.querySelector('svg path[d^="M7.5,12c0,0.83-0.67,1.5-1.5"]').closest("button").click();}},300);}
},7);
}}

/*------------------------------------------------------------------------------
4.2.2.1 LIVECHAT
Expand Down Expand Up @@ -306,10 +321,9 @@ ImprovedTube.channelVideosCount = function () {
------------------------------------------------------------------------------*/

ImprovedTube.description = function (el) {
if (this.storage.description === "classic_expanded" || this.storage.description === "expanded" ) {
if(el){el.click();} else {document.querySelector("#more").click() || document.querySelector("#expand").click() ;}
}
};
if (this.storage.description === "classic_expanded" || this.storage.description === "expanded" )
if(el)try{el.click()}catch{setTimeout(function(){el.click();},700);}
};

/*------------------------------------------------------------------------------
4.2.3.4 HIDE DETAIL BUTTON
Expand Down
6 changes: 5 additions & 1 deletion options-page/skeleton-parts/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,11 @@ extension.skeleton.main.layers.section.appearance.on.click.sidebar = {
click: {
component: "section",
variant: "card",

transcript: {
component: 'switch',
text: 'Transcript',
value: false
},
related_videos: {
component: "select",
text: "relatedVideos",
Expand Down

0 comments on commit b467b28

Please sign in to comment.