Export Shopify Fullsize File URLs

Export all fullsize file URLs from Shopify to clipboard and log them in console (bulk export)

当前为 2024-05-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Export Shopify Fullsize File URLs
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description Export all fullsize file URLs from Shopify to clipboard and log them in console (bulk export)
  6. // @author sharmanhall
  7. // @match https://admin.shopify.com/store/*/content/files?limit=*&selectedView=all
  8. // @match https://admin.shopify.com/store/*/content/files*
  9. // @grant GM_setClipboard
  10. // @grant GM_log
  11. // @run-at document-end
  12. // @license MIT
  13. // @icon https://www.google.com/s2/favicons?sz=64&domain=shopify.com
  14. // @compatible chrome
  15. // @compatible edge
  16. // @compatible firefox
  17. // @compatible safari
  18. // @compatible brave
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. // Function to extract file URLs
  25. function extractFileUrls() {
  26. // Select all elements that contain file URLs using the provided selector
  27. const fileElements = document.querySelectorAll('td._ThumbnailCell_b1ynd_1.Polaris-IndexTable__TableCell div > div > button > span img');
  28.  
  29. // Extract URLs from the elements and convert to fullsize image URLs
  30. const fileUrls = Array.from(fileElements).map(el => el.src.replace('_60x60', ''));
  31.  
  32. // Log the URLs to the console
  33. console.log('Fullsize File URLs:', fileUrls);
  34.  
  35. // Copy URLs to clipboard
  36. GM_setClipboard(fileUrls.join('\n'));
  37.  
  38. // Log success message
  39. GM_log('Fullsize file URLs copied to clipboard.');
  40. }
  41.  
  42. // Function to create a floating button for extracting URLs
  43. function createFloatingButton() {
  44. const button = document.createElement('button');
  45. button.innerText = 'Export File URLs';
  46. button.style.position = 'fixed';
  47. button.style.bottom = '10px';
  48. button.style.right = '10px';
  49. button.style.zIndex = '1000';
  50. button.style.padding = '10px';
  51. button.style.backgroundColor = '#008CBA';
  52. button.style.color = 'white';
  53. button.style.border = 'none';
  54. button.style.borderRadius = '5px';
  55. button.style.cursor = 'pointer';
  56.  
  57. button.addEventListener('click', extractFileUrls);
  58.  
  59. document.body.appendChild(button);
  60. }
  61.  
  62. // Function to create a floating input area for changing the limit parameter
  63. function createLimitInput() {
  64. const container = document.createElement('div');
  65. container.style.position = 'fixed';
  66. container.style.bottom = '50px';
  67. container.style.right = '10px';
  68. container.style.zIndex = '1000';
  69. container.style.padding = '10px';
  70. container.style.backgroundColor = '#fff';
  71. container.style.border = '1px solid #ccc';
  72. container.style.borderRadius = '5px';
  73.  
  74. const label = document.createElement('label');
  75. label.innerText = 'Set Limit: ';
  76. label.style.marginRight = '5px';
  77.  
  78. const input = document.createElement('input');
  79. input.type = 'number';
  80. input.value = 10;
  81. input.style.marginRight = '5px';
  82. input.style.width = '50px';
  83.  
  84. const setButton = document.createElement('button');
  85. setButton.innerText = 'Set';
  86. setButton.style.padding = '5px';
  87. setButton.style.backgroundColor = '#008CBA';
  88. setButton.style.color = 'white';
  89. setButton.style.border = 'none';
  90. setButton.style.borderRadius = '5px';
  91. setButton.style.cursor = 'pointer';
  92.  
  93. setButton.addEventListener('click', () => {
  94. const limit = input.value;
  95. const currentUrl = new URL(window.location.href);
  96. currentUrl.searchParams.set('limit', limit);
  97. window.location.href = currentUrl.toString();
  98. });
  99.  
  100. container.appendChild(label);
  101. container.appendChild(input);
  102. container.appendChild(setButton);
  103.  
  104. document.body.appendChild(container);
  105. }
  106.  
  107. // Function to create quick change buttons
  108. function createQuickChangeButtons() {
  109. const limits = [10, 50, 100, 200, 250];
  110. const container = document.createElement('div');
  111. container.style.position = 'fixed';
  112. container.style.bottom = '110px';
  113. container.style.right = '10px';
  114. container.style.zIndex = '1000';
  115. container.style.padding = '10px';
  116. container.style.backgroundColor = '#fff';
  117. container.style.border = '1px solid #ccc';
  118. container.style.borderRadius = '5px';
  119. container.style.display = 'flex';
  120. container.style.flexDirection = 'column';
  121. container.style.gap = '5px';
  122.  
  123. limits.forEach(limit => {
  124. const button = document.createElement('button');
  125. button.innerText = `Set Limit ${limit}`;
  126. button.style.padding = '5px';
  127. button.style.backgroundColor = '#008CBA';
  128. button.style.color = 'white';
  129. button.style.border = 'none';
  130. button.style.borderRadius = '5px';
  131. button.style.cursor = 'pointer';
  132.  
  133. button.addEventListener('click', () => {
  134. const currentUrl = new URL(window.location.href);
  135. currentUrl.searchParams.set('limit', limit);
  136. window.location.href = currentUrl.toString();
  137. });
  138.  
  139. container.appendChild(button);
  140. });
  141.  
  142. document.body.appendChild(container);
  143. }
  144.  
  145. // Wait for the page to fully load
  146. window.addEventListener('load', () => {
  147. createFloatingButton();
  148. createLimitInput();
  149. createQuickChangeButtons();
  150. });
  151.  
  152. })();