Moby Credits Textifier 2024

extract credits from mobygames - I'm using a temporary email for this greasyfork so don't expect updates <3

  1. // ==UserScript==
  2. // @name Moby Credits Textifier 2024
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @copyright https://en.wikipedia.org/wiki/WTFPL
  6. // @license WTFPL
  7. // @description extract credits from mobygames - I'm using a temporary email for this greasyfork so don't expect updates <3
  8. // @author Curious, aren't we?
  9. // @match https://www.mobygames.com/game/*/*/credits/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=mobygames.com
  11. // @require https://code.jquery.com/jquery-3.7.1.min.js
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. // Your code here...
  19.  
  20. function waitForElm(selector) {
  21. return new Promise(resolve => {
  22. if (document.querySelector(selector)) {
  23. return resolve(document.querySelector(selector));
  24. }
  25.  
  26. const observer = new MutationObserver(mutations => {
  27. if (document.querySelector(selector)) {
  28. observer.disconnect();
  29. resolve(document.querySelector(selector));
  30. }
  31. });
  32.  
  33. // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
  34. observer.observe(document.body, {
  35. childList: true,
  36. subtree: true
  37. });
  38. });
  39. }
  40.  
  41. waitForElm('main#main').then((elm) => {
  42. var $ = window.jQuery;
  43. $('h1').after('<textarea style="background-color: LemonChiffon;" id="mobyex-txt"></textarea><button id="mobyex-btn">allText</button>');
  44. $('#mobyex-btn').click(function(){
  45. var txtCredits = '';
  46. $('table.table-credits > tbody > tr').each(function(){
  47. $(this).find('th h4').each(function(){
  48. txtCredits += '\n\n' + $(this).text();
  49. });
  50. if ( $(this).find('td').length ) {
  51. $(this).find('td:nth-child(1)').each(function(){
  52. txtCredits += '\n\n' + $(this).text();
  53. });
  54. //$(this).find('td:nth-child(2) ul li').each(function(){ // not since 2024-03-14 or so
  55. $(this).find('td:nth-child(2)').text().split(', ').forEach(function(item, index){
  56. //txtCredits += '\n' + $(this).text();
  57. txtCredits += '\n' + item;
  58. });
  59. }
  60. });
  61. $('#mobyex-txt').text(txtCredits.trim());
  62. });
  63. });
  64. })();