Artstation get Images links to Download

Add a button to copy all image links at Artstation page for bulk download or download.

  1. // ==UserScript==
  2. // @name Artstation get Images links to Download
  3. // @namespace Violentmonkey Scripts
  4. // @version 1.0.5
  5. // @description Add a button to copy all image links at Artstation page for bulk download or download.
  6. // @author Wizzergod
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=www.artstation.com
  8. // @match https://*.artstation.*/*/*
  9. // @exclude https://*.artstation.*/marketplace/*
  10. // @grant GM_setClipboard
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function copyLinksToClipboard() {
  18. var links = Array.from(document.querySelectorAll('a[download]')).map(link => link.href);
  19. var linksText = links.join('\n');
  20. navigator.clipboard.writeText(linksText)
  21. .then(() => {
  22. showNotification('Links copied to clipboard!', 'Copy', 'Download');
  23. })
  24. .catch(error => {
  25. console.error('Error copying links to clipboard:', error);
  26. });
  27. }
  28.  
  29. function downloadLinks() {
  30. var links = Array.from(document.querySelectorAll('a[download]')).map(link => link.href);
  31. links.forEach(link => {
  32. var anchor = document.createElement('a');
  33. anchor.href = link;
  34. anchor.download = '';
  35. anchor.target = '_blank';
  36. anchor.click();
  37. });
  38. showNotification('Downloading images...', '', '');
  39. }
  40.  
  41. function showNotification(message, button1Text, button2Text) {
  42. var notification = document.createElement('div');
  43. notification.style.cssText = `
  44. position: fixed;
  45. top: 10px;
  46. right: 10px;
  47. padding: 10px;
  48. background-color: #fff;
  49. border: 1px solid #ccc;
  50. border-radius: 4px;
  51. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  52. z-index: 9999;
  53. `;
  54.  
  55. var messageElement = document.createElement('span');
  56. messageElement.innerText = message;
  57. notification.appendChild(messageElement);
  58.  
  59. if (button1Text) {
  60. var button1 = document.createElement('button');
  61. button1.innerText = button1Text;
  62. button1.style.marginLeft = '10px';
  63. button1.addEventListener('click', function() {
  64. if (button1Text === 'Copy') {
  65. copyLinksToClipboard();
  66. } else if (button1Text === 'Download') {
  67. downloadLinks();
  68. }
  69. document.body.removeChild(notification);
  70. });
  71. notification.appendChild(button1);
  72. }
  73.  
  74. if (button2Text) {
  75. var button2 = document.createElement('button');
  76. button2.innerText = button2Text;
  77. button2.style.marginLeft = '10px';
  78. button2.addEventListener('click', function() {
  79. downloadLinks();
  80. document.body.removeChild(notification);
  81. });
  82. notification.appendChild(button2);
  83. }
  84.  
  85. document.body.appendChild(notification);
  86.  
  87. setTimeout(function() {
  88. document.body.removeChild(notification);
  89. }, 6000);
  90. }
  91.  
  92. var copyButton = document.createElement('button');
  93. copyButton.innerText = 'Get Links';
  94. copyButton.className = 'bs-btn bs-btn-primary';
  95. copyButton.style.cssText = `
  96. padding: 10px 20px 10px 16px;
  97. border-radius: 8px;
  98. display: flex;
  99. flex-direction: row;
  100. font-weight: 500;
  101. gap: 8px;
  102. justify-content: flex-start;
  103. line-height: 100%;
  104. color: black; /* Set the text color to black */
  105. `;
  106.  
  107. var targetElement = document.querySelector('ul.menu-level-1-buttons.sm-gap-medium');
  108. var listItem = document.createElement('li');
  109. listItem.style.listStyle = 'none'; // Remove the dot style
  110. listItem.appendChild(copyButton);
  111. targetElement.appendChild(listItem);
  112.  
  113. copyButton.addEventListener('click', function() {
  114. showNotification('Choose an action:', 'Copy', 'Download');
  115. });
  116. })();