Size
6.8 KB
Version
1.1.2
Created
Mar 2, 2026
Updated
about 1 month ago
1// ==UserScript==
2// @name Bloxd.io Creative Mode Toggle
3// @description Press F to toggle between survival and creative mode
4// @version 1.1.2
5// @match https://*.bloxd.io/*
6// @icon https://bloxd.io/favicon.ico?v=2
7// @grant GM.getValue
8// @grant GM.setValue
9// ==/UserScript==
10(function() {
11 'use strict';
12
13 console.log('Bloxd.io Creative Mode Toggle loaded');
14
15 let isCreativeMode = false;
16
17 // Wait for the game API to load
18 function waitForGameAPI() {
19 return new Promise((resolve) => {
20 const checkInterval = setInterval(() => {
21 if (window.api && typeof window.api === 'object') {
22 console.log('Bloxd.io API found!', window.api);
23 clearInterval(checkInterval);
24 resolve();
25 }
26 }, 500);
27 });
28 }
29
30 // Function to toggle creative mode
31 async function toggleCreativeMode() {
32 try {
33 console.log('F key pressed - attempting to toggle creative mode');
34
35 if (!window.api) {
36 showNotification('Please join a game first!');
37 console.log('API not available - you need to be in a game');
38 return;
39 }
40
41 // Get player ID
42 const playerId = window.myId || window.playerId;
43
44 if (!playerId) {
45 showNotification('Player ID not found. Make sure you are in a game!');
46 console.log('Player ID not found');
47 return;
48 }
49
50 console.log('Player ID:', playerId);
51 isCreativeMode = !isCreativeMode;
52
53 if (isCreativeMode) {
54 // Enable creative mode features
55 console.log('Enabling creative mode...');
56
57 // Try to give unlimited items
58 try {
59 const creativeItems = [
60 'Stone', 'Dirt', 'Wood', 'Glass', 'Brick',
61 'Sand', 'Gravel', 'Clay', 'Iron Ore', 'Gold Ore',
62 'Diamond Ore', 'Coal Ore', 'Emerald Ore'
63 ];
64
65 for (let item of creativeItems) {
66 try {
67 if (window.api.giveItem) {
68 window.api.giveItem(playerId, item, 999);
69 }
70 } catch {
71 console.log('Could not give item:', item);
72 }
73 }
74 } catch (e) {
75 console.log('Error giving items:', e);
76 }
77
78 // Try to enable flying
79 try {
80 if (window.api.setPlayerSetting) {
81 window.api.setPlayerSetting(playerId, 'canFly', true);
82 window.api.setPlayerSetting(playerId, 'flySpeed', 2.0);
83 }
84 } catch (e) {
85 console.log('Could not enable flying:', e);
86 }
87
88 // Try to set health to max
89 try {
90 if (window.api.setHealth) {
91 window.api.setHealth(playerId, 100);
92 }
93 } catch (e) {
94 console.log('Could not set health:', e);
95 }
96
97 // Try to set invincibility
98 try {
99 if (window.api.setPlayerSetting) {
100 window.api.setPlayerSetting(playerId, 'invincible', true);
101 }
102 } catch (e) {
103 console.log('Could not set invincibility:', e);
104 }
105
106 showNotification('Creative Mode ENABLED! ✓');
107 console.log('Creative mode enabled');
108
109 } else {
110 // Disable creative mode features
111 console.log('Disabling creative mode...');
112
113 try {
114 if (window.api.setPlayerSetting) {
115 window.api.setPlayerSetting(playerId, 'canFly', false);
116 window.api.setPlayerSetting(playerId, 'invincible', false);
117 }
118 } catch (e) {
119 console.log('Could not disable creative features:', e);
120 }
121
122 showNotification('Survival Mode ENABLED! ✓');
123 console.log('Survival mode enabled');
124 }
125
126 // Log available API methods for debugging
127 console.log('Available API methods:', Object.keys(window.api));
128
129 } catch (error) {
130 console.error('Error toggling creative mode:', error);
131 showNotification('Error: ' + error.message);
132 }
133 }
134
135 // Show notification to user
136 function showNotification(message) {
137 const notification = document.createElement('div');
138 notification.textContent = message;
139 notification.style.cssText = `
140 position: fixed;
141 top: 20px;
142 right: 20px;
143 background: rgba(0, 0, 0, 0.9);
144 color: #00ff00;
145 padding: 15px 25px;
146 border-radius: 10px;
147 font-family: 'Courier New', monospace;
148 font-size: 16px;
149 font-weight: bold;
150 z-index: 999999;
151 box-shadow: 0 4px 15px rgba(0, 255, 0, 0.3);
152 border: 2px solid #00ff00;
153 animation: slideIn 0.3s ease-out;
154 `;
155
156 // Add animation
157 const style = document.createElement('style');
158 style.textContent = `
159 @keyframes slideIn {
160 from {
161 transform: translateX(400px);
162 opacity: 0;
163 }
164 to {
165 transform: translateX(0);
166 opacity: 1;
167 }
168 }
169 `;
170 document.head.appendChild(style);
171
172 document.body.appendChild(notification);
173
174 setTimeout(() => {
175 notification.style.transition = 'opacity 0.3s';
176 notification.style.opacity = '0';
177 setTimeout(() => notification.remove(), 300);
178 }, 3000);
179 }
180
181 // Listen for F key press
182 document.addEventListener('keydown', (event) => {
183 if (event.key === 'f' || event.key === 'F') {
184 // Don't trigger if user is typing in an input field
185 if (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA') {
186 return;
187 }
188
189 event.preventDefault();
190 toggleCreativeMode();
191 }
192 });
193
194 // Initialize
195 console.log('Waiting for game API to load...');
196 waitForGameAPI().then(() => {
197 console.log('Game API loaded! Press F to toggle creative mode');
198 showNotification('Creative Mode Toggle Ready! Press F');
199 });
200
201})();