SECAM lines

Illusion of SECAM specific clutter for any websites you visit

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        SECAM lines
// @description Illusion of SECAM specific clutter for any websites you visit
// @namespace   com.bodqhrohro.secamlines
// @include     *
// @version     0.0.1
// @grant       none
// ==/UserScript==

var SECAM_store = {}

var SECAM_randomHeight = () => (Math.random() * window.innerHeight) |0;

var SECAM_randomColor = () => {
  // get hue
  var colorType = Math.random();
  var color = [ 0, 0, 0, 0 ];
  if (colorType < 0.6) {
    color[0] = 255;
  } else if (colorType < 0.95) {
    color[2] = 255;
  } else {
    color[0] = color[1] = color[2] = 232;
  }

  // get brightness
  var brightness = 0.5 + Math.random() / 2
  color[0] *= brightness;
  color[1] *= brightness;
  color[2] *= brightness;

  // get transparency
  color[3] = 0.2 + Math.random() * 0.8

  return 'rgba(' + color.join(',') + ')';
}

var SECAM_generator = () => {
  var ctx = SECAM_store.ctx;

  ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);

  SECAM_store.startHeights.forEach((startHeight) => {
    const linesDensity = 100;
    const maxLineLength = 30;
    for (var i = 0; i < linesDensity; i++) {
      ctx.fillStyle = SECAM_randomColor();
      ctx.fillRect(Math.random() * window.innerWidth, startHeight + Math.random() * SECAM_store.barThickness, Math.random() * maxLineLength, 2);
    }
  })

  window.requestAnimationFrame(SECAM_generator);
}

window.addEventListener('load', () => {
  var overlay = document.createElement('canvas');
  document.body.appendChild(overlay);
  overlay.style.position = 'fixed';
  overlay.style.top = '0px';
  overlay.style.left = '0px';
  overlay.style.width = '100vw';
  overlay.style.height = '100vh';
  overlay.style.pointerEvents = 'none';
  overlay.width = window.innerWidth;
  overlay.height = window.innerHeight;
  overlay.style.zIndex = 100500;
  
  SECAM_store.ctx = overlay.getContext('2d');

  // generate places for two garbled bars, regardless of resolution changes for now
  SECAM_store.barThickness = 30;
  var firstBarHeight = SECAM_randomHeight();
  SECAM_store.startHeights = [ firstBarHeight ];
  if (SECAM_store.barThickness * 2 < window.innerHeight) {
    var secondBarHeight;
    do {
      secondBarHeight = SECAM_randomHeight();
    } while (Math.abs(secondBarHeight - firstBarHeight) >= SECAM_randomHeight.barThickness);
    SECAM_store.startHeights.push(secondBarHeight);
  }
  window.requestAnimationFrame(SECAM_generator);
})