Munzee Convert

Show the name of each type at the convert page

目前为 2023-08-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Munzee Convert
  3. // @namespace https://gf.qytechs.cn/users/156194
  4. // @version 0.7
  5. // @description Show the name of each type at the convert page
  6. // @author rabe85
  7. // @match https://www.munzee.com/m/*/*/admin/convert
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=munzee.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function munzee_convert() {
  16.  
  17. var type = document.getElementsByClassName('munzee-info')[0].getElementsByTagName('img')[0];
  18. if(type) {
  19.  
  20. // Show the credits in convert page title (only virtuals)
  21. var type_src = type.getAttribute('src');
  22. if(type_src.split('/')[type_src.split('/').length - 1] == 'virtual.png') {
  23. var credits = document.getElementsByClassName('convert-count')[0];
  24. if(credits) {
  25. var credits_count = document.getElementsByClassName('convert-count')[0].innerHTML;
  26. document.getElementsByClassName('page-title')[0].getElementsByTagName('p')[0].innerHTML += ' - Credits: ' + credits_count;
  27. }
  28. }
  29.  
  30. // Add title + alt tag to current pin
  31. var current_pin_name = type_src.split('/')[type_src.split('/').length - 1].replace(/_/g,' ');
  32. var current_pin_name_formatted = current_pin_name.substr(0, current_pin_name.length-4).charAt(0).toUpperCase() + current_pin_name.substr(0, current_pin_name.length-4).slice(1);
  33. if(current_pin_name_formatted == 'Virtual') current_pin_name_formatted += ' white'; // add 'white' to uncolored virtuals
  34. type.setAttribute('title', current_pin_name_formatted);
  35. type.setAttribute('alt', current_pin_name_formatted);
  36.  
  37. // Add names, remove credits for virtual colors
  38. var colors0 = document.getElementsByClassName('pin-grid');
  39. for(var c = 0, colors; !!(colors=colors0[c]); c++) {
  40. colors.setAttribute('style', 'flex-basis: 16.66% !important;max-width: 16.66% !important;');
  41. var color_name = colors.getElementsByTagName('img')[0].getAttribute('aria-label');
  42. if(color_name !== null) {
  43. var color_name_formatted_array = color_name.split(' ');
  44. for(var cns = 0, color_name_split; !!(color_name_split=color_name_formatted_array[cns]); cns++) {
  45. color_name_formatted_array[cns] = color_name_formatted_array[cns][0].toUpperCase() + color_name_formatted_array[cns].slice(1);
  46. }
  47. var color_name_formatted_string = '';
  48. var credit_text = '';
  49. if(color_name_formatted_array[0] == 'Virtual') color_name_formatted_string = color_name_formatted_array.slice(1).join(' ');
  50. else color_name_formatted_string = color_name_formatted_array.join(' ');
  51. colors.getElementsByTagName('img')[0].setAttribute('style', 'width: 75px;');
  52. if(colors.getElementsByTagName('p')[0].innerHTML == '1') credit_text = '(1 credit)';
  53. else credit_text = '(' + colors.getElementsByTagName('p')[0].innerHTML + ' credits)';
  54. if(color_name_formatted_array[0] != 'Virtual' || color_name_formatted_array.includes('Trail')) colors.getElementsByTagName('p')[0].innerHTML = color_name_formatted_string + '<br>' + credit_text;
  55. else colors.getElementsByTagName('p')[0].innerHTML = color_name_formatted_string;
  56. colors.getElementsByTagName('p')[0].setAttribute('title', color_name_formatted_string);
  57. }
  58. }
  59. }
  60.  
  61. }
  62.  
  63. // Auf Element der Seite warten
  64. function daten_gefunden() {
  65. waitForElm('div.pin-grid').then((elm) => {
  66. munzee_convert();
  67. });
  68. }
  69.  
  70. // Daten nachgeladen?
  71. function waitForElm(selector) {
  72. return new Promise(resolve => {
  73. if (document.querySelector(selector)) {
  74. return resolve(document.querySelector(selector));
  75. }
  76.  
  77. const observer = new MutationObserver(mutations => {
  78. if (document.querySelector(selector)) {
  79. resolve(document.querySelector(selector));
  80. observer.disconnect();
  81. }
  82. });
  83.  
  84. observer.observe(document.body, {
  85. childList: true,
  86. subtree: true
  87. });
  88. });
  89. }
  90.  
  91. // DOM vollständig aufgebaut?
  92. if (/complete|interactive|loaded/.test(document.readyState)) {
  93. daten_gefunden();
  94. } else {
  95. document.addEventListener('DOMContentLoaded', daten_gefunden, false);
  96. }
  97.  
  98. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址