|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Gyazo Gif and Video Direct Link Button |
3 | 3 | // @namespace typpi.online |
4 | | -// @version 3.4 |
| 4 | +// @version 3.5 |
5 | 5 | // @description Adds a link button to redirect to the direct video or gif link on Gyazo |
6 | 6 | // @author Nick2bad4u |
7 | 7 | // @license UnLicense |
|
161 | 161 | findTargetElement(); |
162 | 162 | } |
163 | 163 |
|
| 164 | + // Removes the redirect button and tooltip from the DOM if they exist |
164 | 165 | function removeRedirectButton() { |
165 | | - if (!location.href.includes('https://gyazo.com/captures')) { |
166 | | - console.log('Not removing redirect button since not on captures page'); |
167 | | - return; |
168 | | - } |
169 | | - |
170 | | - console.log('Removing redirect button'); |
| 166 | + console.log('Removing redirect button if it exists'); |
171 | 167 | const existingButton = document.getElementById('direct-video-link-button'); |
172 | | - if (existingButton !== null) { |
| 168 | + if (existingButton) { |
173 | 169 | console.log('Existing button found, removing it'); |
174 | 170 | existingButton.remove(); |
175 | 171 | } |
176 | | - console.log('Redirect button removed'); |
| 172 | + const existingTooltip = document.getElementById('tooltip-direct-video-link-button'); |
| 173 | + if (existingTooltip) { |
| 174 | + console.log('Existing tooltip found, removing it'); |
| 175 | + existingTooltip.remove(); |
| 176 | + } |
| 177 | + console.log('Redirect button and tooltip removed'); |
177 | 178 | } |
178 | 179 |
|
179 | 180 | function handlePageChange() { |
|
190 | 191 | function initialize() { |
191 | 192 | console.log('Initializing script'); |
192 | 193 |
|
193 | | - // Remove any existing button to prevent duplicates |
| 194 | + // Remove any existing button and tooltip to prevent duplicates |
194 | 195 | removeRedirectButton(); |
195 | 196 |
|
196 | 197 | handlePageChange(); |
|
202 | 203 | console.log('URL changed from', window.scriptObserver.lastUrl, 'to', currentUrl); |
203 | 204 | window.scriptObserver.lastUrl = currentUrl; |
204 | 205 |
|
205 | | - // Remove any existing button before handling the page change |
| 206 | + // Remove any existing button and tooltip before handling the page change |
206 | 207 | removeRedirectButton(); |
207 | 208 | handlePageChange(); |
208 | 209 | } |
|
0 commit comments