Docscan Enhancement

Multiple enhancements for Docscan

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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();
}
ห