TVDB Episode Input Automation

Automate entering episode data into a TVDB season

  1. // ==UserScript==
  2. // @name TVDB Episode Input Automation
  3. // @match https://thetvdb.com/series/*/seasons/*/bulkadd
  4. // @description Automate entering episode data into a TVDB season
  5. // @license AGPL
  6. // @version 0.0.1.20241126225939
  7. // @namespace https://greasyfork.org/users/937339
  8. // ==/UserScript==
  9.  
  10. const episodeData = [
  11. {
  12. number: '4',
  13. name: 'American Stepdad',
  14. 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.',
  15. date: '2012-11-18',
  16. runtime: 25
  17. },
  18. {
  19. number: '5',
  20. name: "Why Can't We Be Friends?",
  21. 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.",
  22. date: '2012-12-5',
  23. runtime: 25
  24. }
  25. ];
  26.  
  27. function fillEpisodeData(episodes) {
  28. // Get all episode rows
  29. const rows = document.querySelectorAll('.multirow-item');
  30.  
  31. episodes.forEach((episode, index) => {
  32. if (index >= rows.length - 1) {
  33. // Click "Add Another" button if we need more rows
  34. document.querySelector('.multirow-add').click();
  35. }
  36.  
  37. const row = document.querySelectorAll('.multirow-item')[index];
  38.  
  39. // Fill episode number
  40. row.querySelector('input[name="number[]"]').value = episode.number;
  41.  
  42. // Fill episode name
  43. row.querySelector('input[name="name[]"]').value = episode.name;
  44.  
  45. // Fill overview
  46. row.querySelector('textarea[name="overview[]"]').value = episode.overview;
  47.  
  48. // Fill date
  49. if (episode.date) {
  50. row.querySelector('input[name="date[]"]').value = episode.date;
  51. }
  52.  
  53. // Fill runtime
  54. if (episode.runtime) {
  55. row.querySelector('input[name="runtime[]"]').value = episode.runtime;
  56. }
  57. });
  58. }
  59.  
  60. // Add button to trigger the fill
  61. const btn = document.createElement('button');
  62. btn.innerText = 'Auto-fill Episodes';
  63. btn.style.position = 'fixed';
  64. btn.style.top = '10px';
  65. btn.style.right = '10px';
  66. btn.style.zIndex = '9999';
  67. btn.onclick = () => fillEpisodeData(episodeData);
  68. document.body.appendChild(btn);