-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsync.js
More file actions
72 lines (59 loc) · 1.67 KB
/
sync.js
File metadata and controls
72 lines (59 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
window.n
// Copy MAC address
function copy_mac() {
const mac = document.getElementById("mac");
mac.select();
mac.setSelectionRange(0, 99999);
navigator.clipboard.writeText(mac.innerText);
}
// --- Store moves ---
var moves = [];
// Wait for the cube iframe to load
document.getElementById('cube-view').onload = function () {
// Reset moves on load (clear state)
moves = [];
const iframeWindow = document.getElementById('cube-view').contentWindow;
var macs = "D6:B4:0A:E0:62:72";
iframeWindow.prompt = function (...args) {
console.log(...args);
return macs
};
if (iframeWindow) {
const originalLog = iframeWindow.console.log;
iframeWindow.console.log = function (...args) {
originalLog.apply(console, args);
if (args[1] && args[1].type === "MOVE") {
const move1 = args[1].move;
moves.push(move1);
move(move1)
}
}
}
};
// --- Send inverse moves ---
function reset2() {
resetCube()
}
const reversedMoves = new Set(["D", "L", "F"]);
// --- Perform moves (no colors) ---
async function move(mov) {
moves.push(mov)
cube.move(mov)
console.log(`%cMain: ${mov}`, 'color:#9534eb;');
let clockwise = !mov.endsWith("'");;
let face = mov.replace("'", "");
if (reversedMoves.has(face)) {
clockwise = !clockwise;
}
await window.rotateFace(face, clockwise);
}
window.mover = move;
var ifr = document.getElementById('cube-view')
const targetFrame = window.top.frames[0];
function connect() {
targetFrame.postMessage('connect')
}
function reset() {
reset2()
targetFrame.postMessage('reset')
}