Docscan Enhancement

Multiple enhancements for Docscan

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();
}
ห