Reddit image de-framer

Removes the frame from reddit images, replace it with a minimalist image viewer (viewer.js).

目前為 2024-10-08 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Reddit image de-framer
// @namespace   Violentmonkey Scripts
// @match       https://www.reddit.com/media*
// @require     https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.6/viewer.min.js
// @resource    customCSS https://cdnjs.cloudflare.com/ajax/libs/viewerjs/1.11.6/viewer.min.css
// @grant       GM_getResourceText
// @grant       GM_addStyle
// @version     1.0
// @author      ape-that-presses-keys
// @license     MIT
// @description Removes the frame from reddit images, replace it with a minimalist image viewer (viewer.js).
// ==/UserScript==

// add the image viewer source files to the page
var customCSS = GM_getResourceText("customCSS");
GM_addStyle(customCSS);

// replace the body with the elements needed for the image viewer
let image_url = document.querySelector("zoomable-img > img").src;
document.body.innerHTML = `
<div style="
    background-color: #282828;
    height: 100%;
    width: 100%;
    position: fixed;"
></div>
<div>
    <img id="image" src="${image_url}" alt="Picture">
</div>
`;

// setup and show the viewer
const viewer = new Viewer(document.getElementById('image'), {
    backdrop: false,
    button: false,
    navbar: false,
    title: false,
    toolbar: false,
    initialCoverage: 1.0,
    inline: false,
    rotatable: false,
    scalable: false,
    zoomable: true
});
viewer.show();

// image has been shown and viewed in the viewer
let i = document.querySelector("#image");
i.style.display = "none";