Docscan Enhancement

Multiple enhancements for Docscan

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @namespace     https://github.com/lukespacewalker
// @name          Docscan Enhancement
// @author        Suttisak Denduangchai
// @description   Multiple enhancements for Docscan
// @copyright     2025, Suttisak Denduangchai (https://github.com/lukespacewalker)
// @license       MIT
// @version       1.0.2
// @include       https://dscanweb.bdms.co.th/*
// @grant         GM_addStyle
// @grant         GM.xmlHttpRequest
// @connect       dscanweb.bdms.co.th
// @require       https://cdn.jsdelivr.net/npm/@trim21/[email protected]
// ==/UserScript==

function addStyles() {
    'use strict';

    GM_addStyle(`
#search .left-content {
height: calc(100dvh - 41.47px);
width: 300px;
display:flex;
flex-direction: column;
}

#content{
padding-left:300px;
}

#search .tab-content{
flex: 1 0 auto;
overflow-y:auto;
overflow-x:hidden;
    white-space: unset;
}
    `);
}


function removeTimeout() {
    window.clearInterval(unsafeWindow.timer)
    unsafeWindow.timer = null
}

function removeTrash(){
    document.querySelector(".image-wrapper").remove()

    const targetElement = document.querySelector(".tab-content");

const observer = new MutationObserver(function(mutationsList) {
    for (const mutation of mutationsList) {
        if (mutation.type === 'attributes' && mutation.attributeName === 'style') {
            const currentHeight = mutation.target.style.height;
            const currentOverflow = mutation.target.style.overflow;
            if (currentHeight) {
                targetElement.style.removeProperty("height")
            }
            if (currentOverflow) {
                targetElement.style.removeProperty("overflow")
            }
        }
    }
});

// Configuration of the observer:
const config = {
    attributes: true,
    attributeFilter: ['style'] // Only observe the 'style' attribute
};

// Start observing the target element
observer.observe(targetElement, config);
}

var fetch_timer = null

async function updateSessionCookie(){
    window.clearTimeout(fetch_timer)
    unsafeWindow.timer = window.setTimeout(updateSessionCookie, 1 + Math.random() * 1000 * 60 * 10)

    const res = await GM_fetch("https://dscanweb.bdms.co.th/main", { method: "GET" });
}

function main() {
    removeTimeout();
    removeTrash();
    addStyles();
    updateSessionCookie();
}

/*
    Run the main function on DOMContentLoaded
*/
if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", main);
} else {
    main();
}
ห