Reading Ruler

A firefox addon that adds a horizontal translucent bar that follows the cursor. A reading aid for pages with wiiiiiiide paragraphs.

目前為 2018-09-22 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reading Ruler
// @namespace    https://old.reddit.com/r/SomebodyMakeThis/comments/9huwbw/smt_a_firefox_addon_that_adds_a_horizontal/
// @version      0.1
// @description  A firefox addon that adds a horizontal translucent bar that follows the cursor. A reading aid for pages with wiiiiiiide paragraphs.
// @author       /r/defproc
// @match        */*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var bar = document.createElement("div");
    var styles = {
        left: 0,
        right: 0,
        height: "1.25em",
        backgroundColor: "#00ff0012",
        position: "absolute",
        transform: "translateY(-50%)",
        display: "none",
        pointerEvents: "none",
        transition: "120ms height"
    };
    Object.keys(styles).forEach(function(k){ bar.style[k] = styles[k] });
    document.body.addEventListener("mousemove", function(ev){
        bar.style.top = ev.clientY + "px";
        if(visible){
            var over = document.elementFromPoint(ev.clientX, ev.clientY);
            bar.style.height = window.getComputedStyle(over).getPropertyValue("line-height");
        }
    });
    var visible = false;
    var toggle = function(){
        visible = !visible;
        document.body.appendChild(bar);
        bar.style.display = visible ? "block" : "none";
    };
    window.addEventListener("keypress", function(ev){
        if(ev.ctrlKey && ev.altKey) toggle();
    });

})();