|
1 | 1 | function styledLog(message, style) { |
2 | | - console.log(`%c${message}`, style); |
| 2 | + console.log(`%c${message}`, style) |
3 | 3 | } |
4 | 4 |
|
5 | | -function runTopLogs() { |
6 | | - console.log('%cdiscord.gg/interstellar', 'font-weight: bold; font-size: 39px; color: red; text-shadow: 3px 3px 0 rgb(217,31,38), 6px 6px 0 rgb(226,91,14), 9px 9px 0 rgb(245,221,8), 12px 12px 0 rgb(5,148,68), 15px 15px 0 rgb(2,135,206), 18px 18px 0 rgb(4,77,145), 21px 21px 0 rgb(42,21,113); margin-bottom: 12px; padding: 5%;'); |
7 | | - console.log('%cCredits to @xbubbo and @xderpman on Discord.', 'font-weight: bold; font-size: 20px; color: blue;'); |
8 | | - console.log('%cYou can use this code with proper credits.', 'font-weight: bold; font-size: 20px; color: purple;'); |
9 | | -} |
| 5 | +// Made by discord.gg/interstellar |
| 6 | +// Credits to @xbubbo and @xderpman on Discord |
| 7 | +// You can use this code with proper credits. |
10 | 8 |
|
11 | | -var adjustmentCompleted = false; |
12 | | -var attempts = 0; |
| 9 | +var adjustmentCompleted = false |
| 10 | +var attempts = 0 |
13 | 11 |
|
14 | 12 | function adjustElements() { |
15 | | - if (adjustmentCompleted) { |
16 | | - console.log('%cNow.GG Adjustment already completed. Stopping script.', 'font-size: 30px; color: green;'); |
17 | | - return true; |
| 13 | + if (adjustmentCompleted) { |
| 14 | + console.log('%cNow.GG Adjustment already completed. Stopping script.', 'font-size: 15px; color: green;') |
| 15 | + return true |
| 16 | + } |
| 17 | + |
| 18 | + var iframe = top.document.getElementById('iframeId') |
| 19 | + |
| 20 | + if (iframe) { |
| 21 | + var innerDoc = iframe.contentWindow.document |
| 22 | + |
| 23 | + var roblox = innerDoc.getElementById('js-game-video') |
| 24 | + var controlBar = innerDoc.getElementById('ng-control-bar') |
| 25 | + var fullscreen = innerDoc.getElementById('ng-fs') || innerDoc.querySelector('.sc-kOcGyv.dkAhwC') |
| 26 | + |
| 27 | + if (roblox && controlBar) { |
| 28 | + roblox.style.top = '415px' |
| 29 | + controlBar.style.top = '91%' |
| 30 | + console.log('%cSuccessfully adjusted Now.GG.', 'font-size: 15px; color: green;') |
| 31 | + |
| 32 | + if (fullscreen) { |
| 33 | + // Remove any existing event listeners before adding a new one |
| 34 | + fullscreen.removeEventListener('mousedown', fullscreenClickHandler) |
| 35 | + |
| 36 | + // Add the event listener |
| 37 | + fullscreen.addEventListener('mousedown', fullscreenClickHandler) |
| 38 | + } else { |
| 39 | + console.log('%cFullscreen button not found.', 'font-size: 15px; color: red;') |
| 40 | + } |
| 41 | + |
| 42 | + adjust() |
| 43 | + |
| 44 | + return true |
| 45 | + } else { |
| 46 | + console.log('%cFailed to find elements (roblox or controlBar).', 'font-size: 15px; color: red;') |
| 47 | + return false |
18 | 48 | } |
| 49 | + } else { |
| 50 | + console.log('%cFailed to find iframe with the specified ID.', 'font-size: 15px; color: red;') |
| 51 | + return false |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +function CheckAndAdjust() { |
| 56 | + var intervalId = setInterval(function () { |
| 57 | + RunTopLogs() |
| 58 | + attempts++ |
| 59 | + if (adjustElements()) { |
| 60 | + clearInterval(intervalId) |
| 61 | + } else if (attempts >= 10) { |
| 62 | + console.log( |
| 63 | + '%cNow.GG Script ran 10 times without finding elements. Stopping script.', |
| 64 | + 'font-size: 15px; color: red;' |
| 65 | + ) |
| 66 | + clearInterval(intervalId) |
| 67 | + } |
| 68 | + }, 5000) |
| 69 | +} |
19 | 70 |
|
20 | | - var iframe = top.document.getElementById('iframeId'); |
| 71 | +function adjust() { |
| 72 | + setInterval(function () { |
| 73 | + var iframe = top.document.getElementById('iframeId') |
21 | 74 |
|
22 | 75 | if (iframe) { |
23 | | - var innerDoc = iframe.contentWindow.document; |
| 76 | + var innerDoc = iframe.contentWindow.document |
24 | 77 |
|
25 | | - var roblox = innerDoc.getElementById('js-game-video'); |
26 | | - var controlBar = innerDoc.getElementById('ng-control-bar'); |
| 78 | + var roblox = innerDoc.getElementById('js-game-video') |
| 79 | + var controlBar = innerDoc.getElementById('ng-control-bar') |
| 80 | + var customClassElement = innerDoc.querySelector('.sc-rUGft.hLgqJJ') |
27 | 81 |
|
28 | | - if (roblox && controlBar) { |
29 | | - roblox.style.top = '295px'; |
30 | | - controlBar.style.top = '90%'; |
31 | | - console.log('%cSuccessfully adjusted Now.GG.', 'font-size: 30px; color: green;'); |
| 82 | + if (roblox) { |
| 83 | + checkAndAdjustStyles(roblox, 'top', ['415px']) |
| 84 | + } |
32 | 85 |
|
33 | | - adjustmentCompleted = true; |
| 86 | + if (controlBar) { |
| 87 | + checkAndAdjustStyles(controlBar, 'top', ['91%']) |
| 88 | + } |
34 | 89 |
|
35 | | - return true; |
36 | | - } else { |
37 | | - console.log('%cFailed to find elements (roblox or controlBar).', 'font-size: 15px; color: red;'); |
38 | | - return false; |
39 | | - } |
| 90 | + if (customClassElement) { |
| 91 | + customClassElement.remove() |
| 92 | + console.log('%cRemoved class "sc-rUGft hLgqJJ".', 'font-size: 15px; color: green;') |
| 93 | + } |
40 | 94 | } else { |
41 | | - console.log('%cFailed to find iframe with the specified ID.', 'font-size: 15px; color: red;'); |
42 | | - return false; |
| 95 | + console.log('%cFailed to find iframe with the specified ID.', 'font-size: 15px; color: red;') |
43 | 96 | } |
| 97 | + }, 3000) |
44 | 98 | } |
45 | 99 |
|
46 | | -function checkAndAdjust() { |
47 | | - var intervalId = setInterval(function () { |
48 | | - runTopLogs(); |
49 | | - attempts++; |
50 | | - if (adjustElements()) { |
51 | | - clearInterval(intervalId); |
52 | | - } else if (attempts >= 5) { |
53 | | - console.log('%cNow.GG Script ran 5 times without finding elements. Stopping script.', 'font-size: 15px; color: red;'); |
54 | | - clearInterval(intervalId); |
55 | | - } |
56 | | - }, 7000); |
| 100 | +function checkAndAdjustStyles(element, property, targetValues) { |
| 101 | + if (element) { |
| 102 | + var currentStyle = window.getComputedStyle(element)[property] |
| 103 | + |
| 104 | + if (!targetValues.includes(currentStyle)) { |
| 105 | + element.style[property] = targetValues[0] |
| 106 | + console.log(`%cAdjusted ${property} to ${targetValues[0]}.`, 'font-size: 15px; color: green;') |
| 107 | + } |
| 108 | + } else { |
| 109 | + console.log('%cElement is null. Skipping check and adjustment.', 'font-size: 15px; color: red;') |
| 110 | + } |
| 111 | +} |
| 112 | + |
| 113 | +function RunTopLogs() { |
| 114 | + console.log( |
| 115 | + '%cdiscord.gg/interstellar', |
| 116 | + 'font-weight: bold; font-size: 39px; color: red; text-shadow: 3px 3px 0 rgb(217,31,38), 6px 6px 0 rgb(226,91,14), 9px 9px 0 rgb(245,221,8), 12px 12px 0 rgb(5,148,68), 15px 15px 0 rgb(2,135,206), 18px 18px 0 rgb(4,77,145), 21px 21px 0 rgb(42,21,113); margin-bottom: 12px; padding: 5%;' |
| 117 | + ) |
| 118 | +} |
| 119 | + |
| 120 | +var heightAdjusted = false |
| 121 | + |
| 122 | +function fullscreenClickHandler(event) { |
| 123 | + if (event.detail > 1) { |
| 124 | + event.preventDefault() |
| 125 | + return |
| 126 | + } |
| 127 | + |
| 128 | + console.log('%cFullscreen button clicked.', 'font-size: 15px; color: orange;') |
| 129 | + |
| 130 | + console.log('%cAdjusting height to 415px...', 'font-size: 15px; color: orange;') |
| 131 | + |
| 132 | + var iframe = top.document.getElementById('iframeId') |
| 133 | + if (iframe) { |
| 134 | + var innerDoc = iframe.contentWindow.document |
| 135 | + var roblox = innerDoc.getElementById('js-game-video') |
| 136 | + |
| 137 | + setTimeout(function () { |
| 138 | + if (roblox) { |
| 139 | + roblox.style.top = '415px' |
| 140 | + console.log('%cHeight adjusted to 415px.', 'font-size: 15px; color: green;') |
| 141 | + heightAdjusted = true |
| 142 | + } |
| 143 | + }, 3000) |
| 144 | + } |
| 145 | + |
| 146 | + var fullscreen = innerDoc.getElementById('ng-fs') || innerDoc.querySelector('.sc-kOcGyv.dkAhwC') |
| 147 | + if (fullscreen) { |
| 148 | + fullscreen.removeEventListener('mousedown', fullscreenClickHandler) |
| 149 | + |
| 150 | + if (!heightAdjusted) { |
| 151 | + fullscreen.addEventListener('mousedown', fullscreenClickHandler) |
| 152 | + } |
| 153 | + } |
57 | 154 | } |
58 | 155 |
|
59 | | -checkAndAdjust(); |
60 | | -console.log('%cNow.GG Adjustment script started. Checking every 7 seconds.', 'font-size: 15px; color: blue;'); |
| 156 | +CheckAndAdjust() |
| 157 | +console.log('%cNow.GG Adjustment script started. Checking every 5 seconds.', 'font-size: 15px; color: blue;') |
0 commit comments