onexiv

Ultimate Spot Detector

Nov 15th, 2025
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8" />
  5.   <title>Semantic Signature Scanner</title>
  6.   <style>
  7.     body { font-family: monospace; background: #111; color: #eee; padding: 20px; }
  8.     canvas { border: 1px solid #444; image-rendering: pixelated; }
  9.     #output { margin-top: 20px; white-space: pre; font-size: 14px; line-height: 1.4; }
  10.   </style>
  11. </head>
  12. <body>
  13.  
  14.   <h1>🧠 Semantic Signature Scanner</h1>
  15.   <input type="file" id="imageInput" accept="image/*" />
  16.   <canvas id="semanticCanvas" width="512" height="512"></canvas>
  17.   <div id="output"></div>
  18.  
  19.   <script>
  20.     const canvas = document.getElementById("semanticCanvas");
  21.     const ctx = canvas.getContext("2d");
  22.     const output = document.getElementById("output");
  23.     const gridSize = 7;
  24.     let semanticDictionary = {};
  25.  
  26.     // Load dictionary
  27.     async function loadDictionary() {
  28.       const res = await fetch("dictionary.json");
  29.       semanticDictionary = await res.json();
  30.     }
  31.  
  32.     // Resolve RGB to phrase
  33.     function resolvePhrase(r, g, b) {
  34.       for (let condition in semanticDictionary) {
  35.         const expr = condition.replace(/R/g, r).replace(/G/g, g).replace(/B/g, b);
  36.         if (eval(expr)) return semanticDictionary[condition];
  37.       }
  38.       return "—";
  39.     }
  40.  
  41.     // Extract semantic grid
  42.     function extractSemanticGrid(ctx, width, height, gridSize) {
  43.       const imageData = ctx.getImageData(0, 0, width, height);
  44.       const data = imageData.data;
  45.       const grid = [];
  46.  
  47.       for (let y = 0; y < height; y += gridSize) {
  48.         const row = [];
  49.         for (let x = 0; x < width; x += gridSize) {
  50.           let r = 0, g = 0, b = 0, count = 0;
  51.           for (let dy = 0; dy < gridSize; dy++) {
  52.             for (let dx = 0; dx < gridSize; dx++) {
  53.               const px = ((y + dy) * width + (x + dx)) * 4;
  54.               r += data[px]; g += data[px + 1]; b += data[px + 2]; count++;
  55.             }
  56.           }
  57.           r = Math.floor(r / count);
  58.           g = Math.floor(g / count);
  59.           b = Math.floor(b / count);
  60.           row.push(resolvePhrase(r, g, b));
  61.         }
  62.         grid.push(row);
  63.       }
  64.  
  65.       return grid;
  66.     }
  67.  
  68.     // Overlay phrases on canvas
  69.     function drawOverlay(grid, gridSize) {
  70.       for (let y = 0; y < grid.length; y++) {
  71.         for (let x = 0; x < grid[y].length; x++) {
  72.           const phrase = grid[y][x];
  73.           ctx.fillStyle = "rgba(0,0,0,0.6)";
  74.           ctx.fillRect(x * gridSize, y * gridSize, gridSize, gridSize);
  75.           ctx.fillStyle = "white";
  76.           ctx.font = "6px monospace";
  77.           ctx.fillText(phrase, x * gridSize + 1, y * gridSize + 6);
  78.         }
  79.       }
  80.     }
  81.  
  82.     // Detect spooky clusters
  83.     function detectPhraseClusters(grid, targetPhrase, minLength = 3) {
  84.       const clusters = [];
  85.       const rows = grid.length;
  86.       const cols = grid[0].length;
  87.  
  88.       // Horizontal
  89.       for (let y = 0; y < rows; y++) {
  90.         let count = 0;
  91.         for (let x = 0; x < cols; x++) {
  92.           count = grid[y][x] === targetPhrase ? count + 1 : 0;
  93.           if (count >= minLength) {
  94.             clusters.push(`"${targetPhrase}" horizontally at row ${y}, cols ${x - count + 1}–${x}`);
  95.           }
  96.         }
  97.       }
  98.  
  99.       // Vertical
  100.       for (let x = 0; x < cols; x++) {
  101.         let count = 0;
  102.         for (let y = 0; y < rows; y++) {
  103.           count = grid[y][x] === targetPhrase ? count + 1 : 0;
  104.           if (count >= minLength) {
  105.             clusters.push(`"${targetPhrase}" vertically at col ${x}, rows ${y - count + 1}–${y}`);
  106.           }
  107.         }
  108.       }
  109.  
  110.       // Diagonal ↘
  111.       for (let y = 0; y <= rows - minLength; y++) {
  112.         for (let x = 0; x <= cols - minLength; x++) {
  113.           let match = true;
  114.           for (let i = 0; i < minLength; i++) {
  115.             if (grid[y + i][x + i] !== targetPhrase) {
  116.               match = false;
  117.               break;
  118.             }
  119.           }
  120.           if (match) {
  121.             clusters.push(`"${targetPhrase}" diagonally ↘ from (${x}, ${y})`);
  122.           }
  123.         }
  124.       }
  125.  
  126.       return clusters;
  127.     }
  128.  
  129.     // Handle image input
  130.     document.getElementById("imageInput").addEventListener("change", async (e) => {
  131.       await loadDictionary();
  132.       const file = e.target.files[0];
  133.       if (!file) return;
  134.  
  135.       const img = new Image();
  136.       img.onload = () => {
  137.         canvas.width = img.width;
  138.         canvas.height = img.height;
  139.         ctx.clearRect(0, 0, canvas.width, canvas.height);
  140.         ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
  141.  
  142.         const signatureGrid = extractSemanticGrid(ctx, canvas.width, canvas.height, gridSize);
  143.         drawOverlay(signatureGrid, gridSize);
  144.  
  145.         output.innerText = signatureGrid.map(row => row.join(" ")).join("\n");
  146.  
  147.       };
  148.       img.src = URL.createObjectURL(file);
  149.     });
  150.   </script>
  151. </body>
  152. </html>
  153.  
Advertisement
Add Comment
Please, Sign In to add comment