Desktop Mode & Disable DPI Detection

Forces the browser to use desktop mode and prevents sites from determining the browser DPI

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Desktop Mode & Disable DPI Detection
// @namespace    http://dmxdpi.41
// @version      1.0
// @description  Forces the browser to use desktop mode and prevents sites from determining the browser DPI
// @author       FortyOne
// @license MIT
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

    // Set viewport meta tag to ensure desktop mode
    var viewport = document.createElement('meta');
    viewport.setAttribute('name', 'viewport');
    viewport.setAttribute('content', 'width=1200, user-scalable=yes');
    document.head.appendChild(viewport);

    // Prevent sites from determining browser DPI
    Object.defineProperty(window.screen, 'deviceXDPI', { value: 96, writable: false, configurable: false });
    Object.defineProperty(window.screen, 'logicalXDPI', { value: 96, writable: false, configurable: false });
    Object.defineProperty(window.screen, 'devicePixelRatio', { value: 1, writable: false, configurable: false });
})();