Greasy Fork is available in English.
Hacker mini game
// ==UserScript==
// @name Hacker Terminal PRO
// @namespace Hacker.Terminal.PRO
// @version 3.0
// @author c0pyc4t
// @description Hacker mini game
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// جلوگیری از دوبار اجرا
if (document.getElementById("hacker-terminal-toggle")) return;
// --------------------
// 💾 LOAD STATE
// --------------------
let state = JSON.parse(localStorage.getItem("hackerState")) || {
xp: 0,
theme: "matrix"
};
function save() {
localStorage.setItem("hackerState", JSON.stringify(state));
}
// --------------------
// 🎨 THEMES
// --------------------
const themes = {
matrix: {bg:"#000", color:"#00ff88"},
hacker: {bg:"#050505", color:"#00ffaa"},
neon: {bg:"#111", color:"#ff00ff"}
};
// --------------------
// 🔊 SOUND
// --------------------
function beep() {
const ctx = new (window.AudioContext || window.webkitAudioContext)();
const osc = ctx.createOscillator();
osc.type = "square";
osc.frequency.value = 600;
osc.connect(ctx.destination);
osc.start();
setTimeout(()=>osc.stop(), 100);
}
// --------------------
// 🟢 TOGGLE BUTTON
// --------------------
const toggleBtn = document.createElement("button");
toggleBtn.id = "hacker-terminal-toggle";
toggleBtn.innerText = "🟢 Terminal";
toggleBtn.style = `
position:fixed;bottom:20px;left:20px;z-index:999999;
padding:10px;background:black;color:#00ff88;border:2px solid #00ff88;
font-family:monospace;cursor:pointer;`;
document.body.appendChild(toggleBtn);
// --------------------
// 🧠 TERMINAL
// --------------------
const container = document.createElement("div");
container.style = `
position:fixed;bottom:60px;right:20px;width:340px;
background:${themes[state.theme].bg};
color:${themes[state.theme].color};
font-family:monospace;padding:10px;border:2px solid ${themes[state.theme].color};
display:none;z-index:999999;cursor:move;
`;
container.innerHTML = `
<div id="header">🟢 Hacker Terminal | XP: <span id="xp">${state.xp}</span></div>
<button id="mode1">Password</button>
<button id="mode2">Pattern</button>
<button id="mode3">Decode</button>
<button id="themeBtn">Theme</button>
<div id="gameArea" style="margin-top:10px;"></div>
`;
document.body.appendChild(container);
const gameArea = container.querySelector("#gameArea");
// --------------------
// 🔄 TOGGLE
// --------------------
toggleBtn.onclick = () => {
container.style.display =
container.style.display === "none" ? "block" : "none";
};
// --------------------
// ⌨️ KEYBIND (~)
// --------------------
document.addEventListener("keydown", (e)=>{
if (e.key === "`") {
toggleBtn.click();
}
});
// --------------------
// 🖱️ DRAGGING
// --------------------
let isDragging = false, offsetX, offsetY;
container.addEventListener("mousedown", (e)=>{
isDragging = true;
offsetX = e.clientX - container.offsetLeft;
offsetY = e.clientY - container.offsetTop;
});
document.addEventListener("mousemove", (e)=>{
if (!isDragging) return;
container.style.left = (e.clientX - offsetX) + "px";
container.style.top = (e.clientY - offsetY) + "px";
});
document.addEventListener("mouseup", ()=> isDragging = false);
// --------------------
// 🎨 THEME SWITCH
// --------------------
container.querySelector("#themeBtn").onclick = () => {
const keys = Object.keys(themes);
let index = keys.indexOf(state.theme);
state.theme = keys[(index+1)%keys.length];
save();
location.reload();
};
// --------------------
// 🔐 PASSWORD GAME
// --------------------
container.querySelector("#mode1").onclick = () => {
const words = ["TORN","HACK","CODE","DATA"];
const answer = words[Math.floor(Math.random()*words.length)];
gameArea.innerHTML = `
<input id="guess" maxlength="4"/>
<button id="go">Enter</button>
<div id="res"></div>`;
gameArea.querySelector("#go").onclick = ()=>{
const g = gameArea.querySelector("#guess").value.toUpperCase();
let r = "";
for(let i=0;i<4;i++){
if(g[i]===answer[i]) r+="🟩";
else if(answer.includes(g[i])) r+="🟨";
else r+="⬛";
}
gameArea.querySelector("#res").innerText = r;
beep();
if(g===answer){
state.xp+=10; save();
document.getElementById("xp").innerText = state.xp;
gameArea.innerHTML+="<p>ACCESS GRANTED</p>";
}
};
};
// --------------------
// 🧩 PATTERN
// --------------------
container.querySelector("#mode2").onclick = ()=>{
const p = Array.from({length:5},()=>Math.floor(Math.random()*9));
gameArea.innerHTML = `<p>${p.join(" ")}</p>`;
setTimeout(()=>{
gameArea.innerHTML = `
<input id="inp"/>
<button id="chk">Check</button>
<div id="out"></div>`;
gameArea.querySelector("#chk").onclick=()=>{
const val = gameArea.querySelector("#inp").value;
gameArea.querySelector("#out").innerText =
val===p.join(" ")?"✅":"❌";
beep();
if(val===p.join(" ")){
state.xp+=5; save();
document.getElementById("xp").innerText = state.xp;
}
};
},2000);
};
// --------------------
// 🔤 DECODE
// --------------------
container.querySelector("#mode3").onclick = ()=>{
const words=["SYSTEM","ACCESS","NETWORK","ENCRYPT"];
const w = words[Math.floor(Math.random()*words.length)];
const s = w.split('').sort(()=>0.5-Math.random()).join('');
gameArea.innerHTML = `
<p>${s}</p>
<input id="inp"/>
<button id="chk">Decode</button>
<div id="out"></div>`;
gameArea.querySelector("#chk").onclick=()=>{
const val = gameArea.querySelector("#inp").value.toUpperCase();
gameArea.querySelector("#out").innerText =
val===w?"✅":"❌";
beep();
if(val===w){
state.xp+=7; save();
document.getElementById("xp").innerText = state.xp;
}
};
};
})();