TVDB Episode Input Automation

Automate entering episode data into a TVDB season

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         TVDB Episode Input Automation
// @match        https://thetvdb.com/series/*/seasons/*/bulkadd
// @description Automate entering episode data into a TVDB season
// @license AGPL
// @version 0.0.1.20241126225939
// @namespace https://greasyfork.org/users/937339
// ==/UserScript==

const episodeData = [
  {
    number: '4',
    name: 'American Stepdad',
    overview: 'When Stan invites his recently widowed mother to move in, she and Roger fall in love and wed; Steve and his friends find a lost movie script.',
    date: '2012-11-18',
    runtime: 25
  },
  {
    number: '5',
    name: "Why Can't We Be Friends?",
    overview: "When Stan decides that Snot isn't cool enough to be Steve's best friend, he tries to separate them by staging a shooting at an ice cream parlor.",
    date: '2012-12-5',
    runtime: 25
  }
];

function fillEpisodeData(episodes) {
    // Get all episode rows
    const rows = document.querySelectorAll('.multirow-item');

    episodes.forEach((episode, index) => {
        if (index >= rows.length - 1) {
            // Click "Add Another" button if we need more rows
            document.querySelector('.multirow-add').click();
        }

        const row = document.querySelectorAll('.multirow-item')[index];

        // Fill episode number
        row.querySelector('input[name="number[]"]').value = episode.number;

        // Fill episode name
        row.querySelector('input[name="name[]"]').value = episode.name;

        // Fill overview
        row.querySelector('textarea[name="overview[]"]').value = episode.overview;

        // Fill date
        if (episode.date) {
            row.querySelector('input[name="date[]"]').value = episode.date;
        }

        // Fill runtime
        if (episode.runtime) {
            row.querySelector('input[name="runtime[]"]').value = episode.runtime;
        }
    });
}

// Add button to trigger the fill
const btn = document.createElement('button');
btn.innerText = 'Auto-fill Episodes';
btn.style.position = 'fixed';
btn.style.top = '10px';
btn.style.right = '10px';
btn.style.zIndex = '9999';
btn.onclick = () => fillEpisodeData(episodeData);
document.body.appendChild(btn);