Guest User

Untitled

a guest
Jul 5th, 2024
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. // ==UserScript==
  2. // @name On the rentry 3D
  3. // @version 0.1
  4. // @description Cross-reference Clip Studio Store links with a reference page
  5. // @match https://assets.clip-studio.com/*/*
  6. // ==/UserScript==
  7.  
  8. (function() {
  9. 'use strict';
  10.  
  11. // Define the URL of the reference page
  12. const referenceURL = 'https://rentry.org/CSP_3D';
  13.  
  14. // Fetch the content of the reference page
  15. fetch(referenceURL)
  16. .then(response => response.text())
  17. .then(data => {
  18. // Extract the IDs and DL links from the reference page
  19. const rows = data.match(/<tr>[\s\S]*?<\/tr>/g);
  20. const idDLMap = {};
  21. rows.forEach(row => {
  22. const idMatch = row.match(/<a[^>]*>(\d+)<\/a>/);
  23. if (idMatch) {
  24. const id = idMatch[1];
  25. const dlMatch = row.match(/<a href="([^"]+)"[^>]*>DL<\/a>/);
  26. if (dlMatch) {
  27. const dlLink = dlMatch[1];
  28. idDLMap[id] = dlLink;
  29. }
  30. }
  31. });
  32.  
  33. // Get the current URL's ID
  34. const currentURL = window.location.href;
  35. const currentID = currentURL.match(/detail\?id=(\d+)/)[1];
  36.  
  37. // Check if the current ID is present in the reference IDs
  38. const isPresent = Object.keys(idDLMap).includes(currentID);
  39.  
  40. // Modify the page content accordingly
  41. const contentIdElement = document.querySelector('.materialHeaderContentsId');
  42. if (isPresent) {
  43. const dlLink = idDLMap[currentID];
  44. contentIdElement.innerHTML += ` <a href="${dlLink}" target="_blank">✅ on the Rentry!</a>`;
  45. }
  46. })
  47. .catch(error => console.error('Error fetching data:', error));
  48. })();
Advertisement
Add Comment
Please, Sign In to add comment