Greasy Fork is available in English.

Apple Music - iTunes Artwork Finder Lookup

Add a "🔎 iTunes Artwork Finder" button to Apple Music album pages. Clicking this button will capture the Album and Artist info from the page to the clipboard and open https://bendodson.com/projects/itunes-artwork-finder/, where you can paste the contents of the clipboard to search for high resolution album/cover art. Make sure to change the selectors for the "format" and "country" on iTAF to optimize your results!

  1. // ==UserScript==
  2. // @name Apple Music - iTunes Artwork Finder Lookup
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.7.3
  5. // @description Add a "🔎 iTunes Artwork Finder" button to Apple Music album pages. Clicking this button will capture the Album and Artist info from the page to the clipboard and open https://bendodson.com/projects/itunes-artwork-finder/, where you can paste the contents of the clipboard to search for high resolution album/cover art. Make sure to change the selectors for the "format" and "country" on iTAF to optimize your results!
  6. // @match https://music.apple.com/*/album/*
  7. // @match https://music.apple.com/*/library/albums/*
  8. // @icon https://ptpimg.me/0r4nex.png
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // Function to create the "🔎 iTunes Artwork Finder" button with SVG icon
  17. function createButton(album, artist) {
  18. const button = document.createElement('button');
  19. button.className = 'custom-button';
  20. button.style.cssText = 'background-color: var(--keyColorBG); color: white; border: none; padding: 0px 12px; cursor: pointer; border-radius: 6px; font: var(--body-emphasized); display: flex; align-items: center';
  21.  
  22. // Create the SVG element
  23. const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
  24. svg.setAttribute('viewBox', '0 0 16 16');
  25. svg.setAttribute('width', '13');
  26. svg.setAttribute('height', '13');
  27. svg.style.marginRight = '5px';
  28.  
  29. // Create the path element and set the new d attribute, fill color to white
  30. const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
  31. path.setAttribute('class', 'st0');
  32. path.setAttribute('d', 'M0.9,16c-0.2,0-0.5-0.1-0.7-0.3C0.1,15.5,0,15.3,0,15.1s0.1-0.5,0.3-0.7l4.3-4.3c-0.4-0.5-0.7-1-0.9-1.6C3.4,7.8,3.3,7.1,3.3,6.4c0-0.6,0.1-1.2,0.2-1.7c0.2-0.5,0.4-1.1,0.6-1.5c0.3-0.5,0.6-0.9,1-1.3c0.4-0.4,0.8-0.7,1.3-1c0.5-0.3,1-0.5,1.5-0.6C8.5,0.1,9,0,9.6,0c0.6,0,1.2,0.1,1.7,0.2c0.5,0.1,1.1,0.4,1.5,0.6c0.5,0.3,0.9,0.6,1.3,1c0.4,0.4,0.7,0.8,1,1.3c0.3,0.5,0.5,1,0.6,1.5C15.9,5.2,16,5.8,16,6.4c0,0.6-0.1,1.2-0.2,1.7c-0.2,0.5-0.4,1.1-0.6,1.5c-0.3,0.5-0.6,0.9-1,1.3s-0.8,0.7-1.3,1c-0.5,0.3-1,0.5-1.5,0.6c-0.5,0.1-1.1,0.2-1.7,0.2c-0.7,0-1.5-0.1-2.2-0.4c-0.6-0.2-1.1-0.5-1.6-0.9l-4.3,4.3C1.4,15.9,1.2,16,0.9,16z M9.6,1.9C9.2,1.9,8.8,1.9,8.4,2C8.1,2.1,7.7,2.3,7.4,2.5C7,2.7,6.7,2.9,6.4,3.2C6.2,3.5,5.9,3.8,5.7,4.1C5.5,4.4,5.4,4.8,5.3,5.2C5.2,5.6,5.1,6,5.1,6.4c0,0.6,0.1,1.2,0.4,1.8c0.2,0.5,0.6,1,1,1.4c0.4,0.4,0.9,0.7,1.4,1c0.5,0.2,1.1,0.4,1.8,0.4c0.6,0,1.2-0.1,1.8-0.4c0.5-0.2,1-0.6,1.4-1c0.4-0.4,0.7-0.9,1-1.4C14,7.6,14.1,7,14.1,6.4c0-0.6-0.1-1.2-0.4-1.8c-0.2-0.5-0.6-1-1-1.4c-0.4-0.4-0.9-0.7-1.4-1C10.8,2,10.3,1.9,9.6,1.9z');
  33. path.setAttribute('fill', '#FFFFFF');
  34.  
  35. // Append the path to the SVG
  36. svg.appendChild(path);
  37.  
  38. // Create the text node for "iTunes Artwork Finder"
  39. const buttonText = document.createTextNode(' iTunes Artwork Finder');
  40.  
  41. // Append SVG and text to the button
  42. button.appendChild(svg);
  43. button.appendChild(buttonText);
  44.  
  45. // Copy album and artist to clipboard
  46. button.onclick = function () {
  47. const textToCopy = `${album} ${artist}`;
  48. navigator.clipboard.writeText(textToCopy).then(() => {
  49. window.open('https://bendodson.com/projects/itunes-artwork-finder/', '_blank');
  50. });
  51. };
  52.  
  53. return button;
  54. }
  55.  
  56. // Function to add the button to the primary actions section
  57. function addButton() {
  58. const albumElement = document.querySelector('h1.headings__title span[dir="auto"]');
  59. const artistElement = document.querySelector('div.headings__subtitles');
  60. const primaryActionsDiv = document.querySelector('div.primary-actions');
  61.  
  62. // Check if the button already exists to prevent adding it multiple times
  63. if (albumElement && artistElement && primaryActionsDiv && !document.querySelector('#search-iTAF-button')) {
  64. const album = albumElement.innerText;
  65. const artist = artistElement.innerText;
  66.  
  67. // Create and append the "🔎 iTunes Artwork Findero" button
  68. const button = createButton(album, artist);
  69. button.id = 'search-iTAF-button'; // Assign an ID to the button to track its presence
  70. primaryActionsDiv.appendChild(button);
  71. }
  72. }
  73.  
  74. // Keep checking for changes on the page and add the button once the elements are loaded
  75. function persistentlyAddButton() {
  76. addButton();
  77. setTimeout(persistentlyAddButton, 1000); // Retry every 1 second
  78. }
  79.  
  80. persistentlyAddButton(); // Start the loop to add the button
  81.  
  82. // Handle changes in the URL (e.g., if navigating between albums)
  83. let lastUrl = location.href;
  84. new MutationObserver(() => {
  85. const url = location.href;
  86. if (url !== lastUrl) {
  87. lastUrl = url;
  88. setTimeout(addButton, 1000); // Add button after the URL changes
  89. }
  90. }).observe(document, { subtree: true, childList: true });
  91.  
  92. })();