最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I get the exact date input field in youtube studio to modify the date where my video gets published? - Stack

programmeradmin1浏览0评论

I'm trying to write a script that would automate the scheduling of uploaded videos on youtube. they are already uploaded and currently in draft mode.

however, when I get to the point when I need to change the date value, I'm just not able to exactly get this date field for some reason. Upon checking, the id of the input value increments everytime you close and open it. it appears to be dynamic. it will show the id as input-22 now, but when you close the date selector dropdown, the date input field's ID will become input-23

here's my script so far

(async function() {
console.log(" Starting draft video scheduling...");

// Find draft videos (videos with "Draft" label)
// const drafts = document.querySelectorAll('ytcp-video-row[status="DRAFT"]');
const drafts = document.querySelectorAll('ytcp-video-row');

if (drafts.length === 0) {
    console.log("No draft videos found!");
    return;
}

console.log("Found ${drafts.length} draft(s). Selecting the first one...");

// Click the first draft video to edit
console.log(1)
drafts[0].querySelector("#video-title").click();

// Wait for the details page to load
console.log(2)
await new Promise(resolve => setTimeout(resolve, 2000));

// Click "Visibility" settings button
console.log(3)
document.querySelector("#step-badge-3").click();
await new Promise(resolve => setTimeout(resolve, 1000));

// Select "Schedule"
console.log(4)
document.querySelector('#second-container-expand-button').click();
await new Promise(resolve => setTimeout(resolve, 500));

// Open date picker
console.log(5);
document.querySelector("#datepicker-trigger").click();
await new Promise(resolve => setTimeout(resolve, 1000));

// Set the scheduled date
console.log(6);
const scheduleDate = "February 10, 2025"; // Change this to your desired date
console.log(6.1);

document.querySelector("input.style-scope.tp-yt-paper-input").value = scheduleDate;
console.log('schedule date assigned new value, now displaying again')
console.log(document.querySelector("input.style-scope.tp-yt-paper-input").value)

})();

I tried implementing something using the youtube API for the credits for a free user gets used up after a couple of tries so I'm doing this instead

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论