Project Random - wowee fun question marks

spinny spin

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Project Random - wowee fun question marks
// @namespace   https://greasyfork.org/en/users/945115-unmatchedbracket
// @match       https://0xbeef.co.uk/random*
// @grant       none
// @version     1.0
// @author      Unmatched Bracket
// @description spinny spin
// @license     The Unlicense
// ==/UserScript==

function tickq(e) {
  //requestAnimationFrame(() => tickq(e))

  if (mousepos) {
    let rect = e.getBoundingClientRect()
    let mouseRelX = (rect.left + rect.right) / 2 - mousepos.x
    let mouseRelY = (rect.top + rect.bottom) / 2 - mousepos.y

    let angleToMouse = Math.atan2(mouseRelY, mouseRelX)*180/Math.PI - 90
    let diff = ((e.qdata.angle - angleToMouse) % 360 + 540) % 360 - 180
    let dist = Math.hypot(mouseRelX, mouseRelY)
    e.qdata.momentum -= diff / Math.pow(Math.max(1, dist/50), 2)
  }

  let now = Date.now()
  let delta = now - e.qdata.lasttick
  e.qdata.lasttick = now

  e.qdata.momentum *= 0.95
  e.qdata.momentum += Math.pow(Math.random(), 8)*25
  e.qdata.angle += e.qdata.momentum*delta/1000
  e.style.rotate = e.qdata.angle + "deg"
}

let qs = [...document.getElementsByClassName("mark")]

let container = qs[0].parentElement.parentElement

let mousepos = null

container.addEventListener("mousemove", (e) => {
  mousepos = {x: e.pageX, y: e.pageY}
})

container.addEventListener("mouseenter", (e) => {
  mousepos = {x: e.pageX, y: e.pageY}
})

container.addEventListener("mouseleave", (e) => {
  mousepos = null
})

qs.forEach((e) => {
  e.style.animation = "none"
  //e.style.transition = "rotate 0.2s linear"
  e.qdata = {
    angle: Math.random() * 360,
    momentum: Math.random() * 10
  }
  e.qdata.lasttick = Date.now()
})

function alltick() {
  requestAnimationFrame(alltick)
  qs.forEach((e) => tickq(e))
}

alltick()