TurboWarp to Scratch

Adds a button on TurboWarp projects that links back to Scratch

  1. // ==UserScript==
  2. // @name TurboWarp to Scratch
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Adds a button on TurboWarp projects that links back to Scratch
  6. // @author c00lk1dha4k3r1 -- a scratch user
  7. // @match https://turbowarp.org/*
  8. // @icon https://scratch.mit.edu/favicon.ico
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Function to create the Scratch button
  17. function createScratchButton() {
  18. const projectId = window.location.pathname.split('/')[1];
  19. const scratchUrl = `https://scratch.mit.edu/projects/${projectId}`;
  20.  
  21. const button = document.createElement('a');
  22. button.href = scratchUrl;
  23. button.innerText = 'Open in Scratch';
  24. button.style.position = 'fixed';
  25. button.style.top = '10px';
  26. button.style.right = '10px';
  27. button.style.padding = '10px 20px';
  28. button.style.backgroundColor = '#4d97ff';
  29. button.style.color = '#fff';
  30. button.style.border = 'none';
  31. button.style.borderRadius = '5px';
  32. button.style.textDecoration = 'none';
  33. button.style.fontSize = '16px';
  34. button.style.fontWeight = 'bold';
  35. button.style.cursor = 'pointer';
  36. button.style.zIndex = '1000';
  37.  
  38. document.body.appendChild(button);
  39. }
  40.  
  41. // Check if the document is fully loaded
  42. function checkLoaded() {
  43. if (document.readyState === 'complete') {
  44. createScratchButton();
  45. } else {
  46. window.addEventListener('load', createScratchButton);
  47. }
  48. }
  49.  
  50. checkLoaded();
  51. })();