DE Item Tooltips

Change color of specific text

  1. // ==UserScript==
  2. // @name DE Item Tooltips
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Change color of specific text
  6. // @author BingGPT + NeKpoT
  7. // @match *://dungeoneyes.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. // Function to trim image name
  14. function trimImageName(src) {
  15. if (!src) return null; // Return null if src is undefined
  16.  
  17. var imageName = src.split('/').pop(); // Get the file name
  18. imageName = imageName.replace(/\.[^/.]+$/, ""); // Remove extension
  19. imageName = imageName.replace(/[0-9A-Z]+$/, ""); // Remove trailing digits and capital letters
  20. return imageName;
  21. }
  22.  
  23. // Function to process item description
  24. function processItemDescription(itemDescription) {
  25. var itemName = itemDescription.find('strong').text();
  26. var itemType = itemDescription.find('em').text();
  27. var itemEffect = itemDescription.contents().filter(function() {
  28. return this.nodeType === 3; // Node.TEXT_NODE
  29. }).get(0).nodeValue.trim();
  30. var itemWeightValue = itemDescription.contents().filter(function() {
  31. return this.nodeType === 3; // Node.TEXT_NODE
  32. }).get(1).nodeValue.trim();
  33. return itemName + '\n' + itemType + '\n' + itemEffect + '\n' + itemWeightValue;
  34. }
  35.  
  36. // Fetch the item descriptions page
  37. jQuery.get('/items', function(data) {
  38. var itemDescriptions = jQuery(data).find('p');
  39.  
  40. // Add mouseover event to each image
  41. jQuery('img').on('mouseover', function() {
  42. var src = trimImageName(jQuery(this).attr('src'));
  43. if (!src || !src.startsWith('ITEM')) return; // Skip if src is undefined or does not start with 'ITEM'
  44.  
  45. var itemDescription;
  46.  
  47. // Find the matching item description
  48. itemDescriptions.each(function() {
  49. var itemImgSrc = trimImageName(jQuery(this).find('img').attr('src'));
  50. if (itemImgSrc && itemImgSrc === src) {
  51. itemDescription = jQuery(this);
  52. return false; // break the loop
  53. }
  54. });
  55.  
  56. if (itemDescription) {
  57. // Process the item description and show the tooltip
  58. jQuery(this).attr('title', processItemDescription(itemDescription));
  59. }
  60. });
  61. });
  62.  
  63. })();