YouTube Subscribe Button Themes

Custom animated subscribe button themes

  1. // ==UserScript==
  2. // @name YouTube Subscribe Button Themes
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Custom animated subscribe button themes
  6. // @author NOT_FIND
  7. // @match https://www.youtube.com/*
  8. // @icon https://www.google.com/s2/favicons?domain=youtube.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. const themeSelector = document.createElement('div');
  14. themeSelector.innerHTML = `
  15. <div id="theme-popup" style="display:none;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#202020;padding:20px;border-radius:10px;z-index:9999;box-shadow:0 0 20px rgba(0,0,0,0.5);width:400px">
  16. <h2 style="text-align:center;margin:0 0 20px;color:#fff">Subscribe Button Themes</h2>
  17. <div style="display:flex;justify-content:space-between;margin-bottom:20px">
  18. <div class="theme-preview">
  19. <div class="preview-btn futuristic">SUBSCRIBE</div>
  20. <button class="select-btn" onclick="selectTheme('futuristic')">Select</button>
  21. </div>
  22. <div class="theme-preview">
  23. <div class="preview-btn bendy">SUBSCRIBE</div>
  24. <button class="select-btn" onclick="selectTheme('bendy')">Select</button>
  25. </div>
  26. <div class="theme-preview">
  27. <div class="preview-btn particles">SUBSCRIBE</div>
  28. <button class="select-btn" onclick="selectTheme('particles')">Select</button>
  29. </div>
  30. <div class="theme-preview">
  31. <button class="select-btn" onclick="selectTheme('default')">Default</button>
  32. </div>
  33. </div>
  34. </div>
  35. `;
  36. document.body.appendChild(themeSelector);
  37.  
  38. const styles = document.createElement('style');
  39. styles.textContent = `
  40. .select-btn {
  41. width: 100%;
  42. padding: 5px;
  43. border: none;
  44. border-radius: 4px;
  45. background: #065fd4;
  46. color: white;
  47. cursor: pointer;
  48. }
  49.  
  50. .custom-subscribe-btn {
  51. width: 120px;
  52. height: 40px;
  53. display: flex;
  54. align-items: center;
  55. justify-content: center;
  56. font-family: 'Roboto', sans-serif;
  57. font-weight: 500;
  58. font-size: 14px;
  59. cursor: pointer;
  60. border: none;
  61. margin: 0 4px;
  62. position: relative;
  63. overflow: hidden;
  64. }
  65.  
  66. .preview-btn {
  67. width: 100px;
  68. height: 40px;
  69. display: flex;
  70. align-items: center;
  71. justify-content: center;
  72. margin-bottom: 10px;
  73. font-size: 12px;
  74. font-weight: bold;
  75. position: relative;
  76. overflow: hidden;
  77. }
  78.  
  79. /* Futuristic Theme */
  80. .futuristic {
  81. background: #7b2ff7;
  82. color: white;
  83. position: relative;
  84. overflow: hidden;
  85. border-radius: 5px;
  86. text-transform: uppercase;
  87. letter-spacing: 2px;
  88. transition: all 0.3s;
  89. }
  90. .futuristic::before {
  91. content: '';
  92. position: absolute;
  93. top: 0;
  94. left: -100%;
  95. width: 100%;
  96. height: 100%;
  97. background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  98. transition: 0.5s;
  99. }
  100. .futuristic:hover::before {
  101. left: 100%;
  102. }
  103.  
  104. /* Bendy Theme */
  105. .bendy {
  106. background: #00ff95;
  107. color: black;
  108. border-radius: 8px;
  109. transform-origin: center;
  110. animation: bendAnimation 2s ease-in-out infinite;
  111. }
  112. @keyframes bendAnimation {
  113. 0% { transform: rotateX(0deg) scale(1); }
  114. 25% { transform: rotateX(15deg) scale(1.05); }
  115. 50% { transform: rotateX(0deg) scale(1); }
  116. 75% { transform: rotateX(-15deg) scale(0.95); }
  117. 100% { transform: rotateX(0deg) scale(1); }
  118. }
  119.  
  120. /* Particles Theme */
  121. .particles {
  122. background: #2d2d2d;
  123. color: white;
  124. border-radius: 5px;
  125. }
  126.  
  127. .preview-btn.particles::before,
  128. .preview-btn.particles::after,
  129. .custom-subscribe-btn.particles::before,
  130. .custom-subscribe-btn.particles::after {
  131. content: '❄';
  132. position: absolute;
  133. color: white;
  134. font-size: 10px;
  135. animation: snow 2s linear infinite;
  136. opacity: 0;
  137. z-index: 1;
  138. }
  139.  
  140. .preview-btn.particles::before,
  141. .custom-subscribe-btn.particles::before {
  142. left: 30%;
  143. animation-delay: 0s;
  144. }
  145.  
  146. .preview-btn.particles::after,
  147. .custom-subscribe-btn.particles::after {
  148. left: 70%;
  149. animation-delay: 1s;
  150. }
  151.  
  152. @keyframes snow {
  153. 0% {
  154. top: -20%;
  155. opacity: 0;
  156. }
  157. 50% {
  158. opacity: 0.8;
  159. }
  160. 100% {
  161. top: 120%;
  162. opacity: 0;
  163. }
  164. }
  165. `;
  166. document.head.appendChild(styles);
  167.  
  168. function replaceSubscribeButton(theme) {
  169. const subscribeButton = document.querySelector('#subscribe-button');
  170. if (subscribeButton) {
  171. const oldButton = subscribeButton.querySelector('button');
  172. if (oldButton) {
  173. if (theme === 'default') {
  174. return;
  175. }
  176.  
  177. const newButton = document.createElement('div');
  178. newButton.className = `custom-subscribe-btn ${theme}`;
  179.  
  180. const buttonText = oldButton.textContent.trim().toUpperCase();
  181. const isSubscribed = buttonText === 'SUBSCRIBED' || buttonText === 'UNSUBSCRIBE';
  182.  
  183. newButton.innerHTML = isSubscribed ? 'SUBSCRIBED' : 'SUBSCRIBE';
  184. newButton.onclick = oldButton.onclick;
  185. oldButton.replaceWith(newButton);
  186. }
  187. }
  188. }
  189.  
  190. window.selectTheme = function(theme) {
  191. if (theme === 'default') {
  192. localStorage.removeItem('subscribeTheme');
  193. } else {
  194. localStorage.setItem('subscribeTheme', theme);
  195. }
  196. location.reload();
  197. }
  198.  
  199. window.addEventListener('keydown', (e) => {
  200. if(e.key === ';') {
  201. const popup = document.getElementById('theme-popup');
  202. popup.style.display = popup.style.display === 'none' ? 'block' : 'none';
  203. }
  204. });
  205.  
  206. const observer = new MutationObserver(() => {
  207. const savedTheme = localStorage.getItem('subscribeTheme');
  208. if(savedTheme) {
  209. replaceSubscribeButton(savedTheme);
  210. }
  211. });
  212.  
  213. observer.observe(document.body, {
  214. childList: true,
  215. subtree: true
  216. });
  217.  
  218. const savedTheme = localStorage.getItem('subscribeTheme');
  219. if(savedTheme) {
  220. replaceSubscribeButton(savedTheme);
  221. }