Sıfır bağımlılık, yerel yüksek performanslı hafıza motoru. (TR/EN Dil Destekli)
// ==UserScript==
// @name MemoryLens V5sp: Nexus
// @namespace http://tampermonkey.net/
// @version 8.1
// @description Sıfır bağımlılık, yerel yüksek performanslı hafıza motoru. (TR/EN Dil Destekli)
// @author Mustafa Hakan
// @match *://*/*
// @grant none
// ==/UserScript==
/* jshint esversion: 11 */
(function() {
'use strict';
// --- [1. DİL MOTORU] ---
const userLang = navigator.language.startsWith('tr') ? 'tr' : 'en';
const UI = {
tr: {
placeholder: "Nexus Hafızasında Ara...",
footer: "MEMORYLENS V6 NEXUS",
badge: "KARARLI ÇEKİRDEK",
noResult: "Eşleşen bir kayıt bulunamadı."
},
en: {
placeholder: "Search in Nexus Memory...",
footer: "MEMORYLENS V6 NEXUS",
badge: "STABLE CORE",
noResult: "No matching records found."
}
}[userLang];
const MEMORY = {
dbName: "MemoryLens_V6",
store: "nexus_nodes",
size: 4000
};
const core = {
db: null,
async connect() {
if (this.db) return this.db;
return new Promise(r => {
const req = indexedDB.open(MEMORY.dbName, 1);
req.onupgradeneeded = e => e.target.result.createObjectStore(MEMORY.store, { keyPath: "url" });
req.onsuccess = e => { this.db = e.target.result; r(this.db); };
});
},
async save() {
if (document.hidden) return;
const node = {
url: window.location.href,
title: document.title || "...",
domain: window.location.hostname,
icon: `https://www.google.com/s2/favicons?sz=64&domain=${window.location.hostname}`,
content: document.body.innerText.slice(0, MEMORY.size).replace(/\s+/g, ' ').toLowerCase(),
time: Date.now()
};
const db = await this.connect();
db.transaction(MEMORY.store, "readwrite").objectStore(MEMORY.store).put(node);
}
};
setTimeout(() => core.save(), 4000);
const view = {
active: false,
box: null,
init() {
if (this.box) return;
this.box = document.createElement('div');
this.box.id = 'ml6-root';
this.box.innerHTML = `
<div id="ml6-bg" style="position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.7);z-index:2147483647;display:none;justify-content:center;padding-top:12vh;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);">
<div style="width:640px;background:#111;border:1px solid #333;border-radius:18px;box-shadow:0 30px 60px rgba(0,0,0,0.6);display:flex;flex-direction:column;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
<input type="text" id="ml6-in" placeholder="${UI.placeholder}" style="width:100%;background:transparent;border:none;padding:22px;color:#fff;font-size:19px;outline:none;border-bottom:1px solid #222;" spellcheck="false" autocomplete="off">
<div id="ml6-list" style="max-height:440px;overflow-y:auto;background:#111;"></div>
<div style="padding:12px 22px;background:#0d0d0d;border-top:1px solid #222;display:flex;justify-content:space-between;align-items:center;">
<span style="color:#444;font-size:11px;font-weight:600;letter-spacing:1px;">${UI.footer}</span>
<span style="color:#00ff88;font-size:10px;background:rgba(0,255,136,0.1);padding:3px 8px;border-radius:4px;font-weight:bold;">${UI.badge}</span>
</div>
</div>
</div>
`;
document.body.appendChild(this.box);
this.box.querySelector('#ml6-in').addEventListener('input', e => this.find(e.target.value));
},
async find(q) {
const list = document.getElementById('ml6-list');
if (q.length < 2) {
list.innerHTML = '';
return;
}
const db = await core.connect();
const raw = await new Promise(r => db.transaction(MEMORY.store).objectStore(MEMORY.store).getAll().onsuccess = e => r(e.target.result));
const terms = q.toLowerCase().split(' ');
const match = raw.filter(n => terms.every(t => n.title.toLowerCase().includes(t) || n.content.includes(t) || n.domain.includes(t)))
.sort((a, b) => b.time - a.time).slice(0, 8);
this.draw(match);
},
draw(items) {
const list = document.getElementById('ml6-list');
if (items.length === 0) {
list.innerHTML = `<div style="padding:30px;text-align:center;color:#444;font-size:14px;">${UI.noResult}</div>`;
return;
}
list.innerHTML = items.map(n => `
<div onclick="window.location.href='${n.url}'" style="padding:16px 22px;display:flex;align-items:center;cursor:pointer;border-bottom:1px solid #1a1a1a;transition:background 0.15s;" onmouseover="this.style.background='#1a1a1a'" onmouseout="this.style.background='transparent'">
<img src="${n.icon}" style="width:34px;height:34px;border-radius:8px;margin-right:16px;background:#222;">
<div style="flex:1;min-width:0;">
<div style="color:#eee;font-size:15px;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">${n.title}</div>
<div style="color:#666;font-size:12px;margin-top:3px;display:flex;align-items:center;gap:8px;">
<span>${n.domain}</span>
<span style="width:3px;height:3px;background:#333;border-radius:50%;"></span>
<span>${new Date(n.time).toLocaleDateString()}</span>
</div>
</div>
</div>
`).join('');
},
open() {
this.init();
const bg = document.getElementById('ml6-bg');
this.active = !this.active;
bg.style.display = this.active ? 'flex' : 'none';
if (this.active) {
document.getElementById('ml6-in').value = '';
document.getElementById('ml6-list').innerHTML = '';
document.getElementById('ml6-in').focus();
}
}
};
window.addEventListener('keydown', e => {
if (e.altKey && e.key.toLowerCase() === 'k') { e.preventDefault(); view.open(); }
if (e.key === 'Escape' && view.active) view.open();
});
})();