Talk:Bhadreswar, Hooghly: Difference between revisions

Line 102: Line 102:

});

});

});

});

{

“manifest_version”: 3,

“name”: “DSN First Instance Finder”,

“version”: “1.0”,

“description”: “Ctrl+Click a line to find and highlight the first instance of the DSN value.”,

“permissions”: [“scripting”],

“content_scripts”: [

{

“matches”: [“<all_urls>”],

“js”: [“content.js”],

“css”: [“styles.css”]

}

]

}

{

“manifest_version”: 3,

“name”: “DSN First Instance Finder”,

“version”: “1.0”,

“description”: “Ctrl+Click a line to find and highlight the first instance of the DSN value.”,

“permissions”: [“scripting”],

“content_scripts”: [

{

“matches”: [“<all_urls>”],

“js”: [“content.js”],

“css”: [“styles.css”]

}

]

}

.dsn-highlight {

background: orange;

padding: 2px 3px;

border-radius: 3px;

}

</syntaxhighlight>

</syntaxhighlight>

I am about to start working on this page heavily. Within a week it should be completed.–Iball 19:56, 20 August 2006 (UTC)[reply]

Hello fellow Wikipedians,

I have just modified 2 external links on Bhadreswar, Hooghly. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at {{Sourcecheck}}).

This message was posted before February 2018. After February 2018, “External links modified” talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these “External links modified” talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 5 June 2024).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—InternetArchiveBot (Report bug) 09:35, 1 November 2016 (UTC)[reply]

function clearExistingHighlight() {
    document.querySelectorAll(".dsn-highlight").forEach(span => {
        const parent = span.parentNode;
        parent.replaceChild(document.createTextNode(span.textContent), span);
        parent.normalize();
    });
}

document.addEventListener("click", function (event) {
    // Require Ctrl + Click
    if (!event.ctrlKey) return;

    // Locate clicked position
    const range = document.caretRangeFromPoint
        ? document.caretRangeFromPoint(event.clientX, event.clientY)
        : document.caretPositionFromPoint(event.clientX, event.clientY);

    if (!range) return;

    const node = range.startContainer;
    if (!node || node.nodeType !== Node.TEXT_NODE) return;

    const line = node.textContent;

    // Search for DSN=
    const idx = line.indexOf("DSN=");
    if (idx === -1) return;

    // Extract substring after DSN=
    let afterEquals = line.slice(idx + 4);

    // Stop at comma if present
    const commaIndex = afterEquals.indexOf(",");
    let dsnValue = commaIndex !== -1 ? afterEquals.slice(0, commaIndex) : afterEquals;

    dsnValue = dsnValue.trim();
    if (!dsnValue) return;

    // Clear any previous highlight
    clearExistingHighlight();

    // Find first instance of substring in whole page
    const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);

    let targetNode = null;
    let targetIndex = -1;

    while (walker.nextNode()) {
        const t = walker.currentNode.textContent;
        const pos = t.indexOf(dsnValue);
        if (pos !== -1) {
            targetNode = walker.currentNode;
            targetIndex = pos;
            break;
        }
    }

    if (!targetNode) return;

    // Highlight only the first instance
    const before = targetNode.textContent.slice(0, targetIndex);
    const match = targetNode.textContent.slice(targetIndex, targetIndex + dsnValue.length);
    const after = targetNode.textContent.slice(targetIndex + dsnValue.length);

    const span = document.createElement("span");
    span.textContent = match;
    span.className = "dsn-highlight";

    const parent = targetNode.parentNode;

    parent.insertBefore(document.createTextNode(before), targetNode);
    parent.insertBefore(span, targetNode);
    parent.insertBefore(document.createTextNode(after), targetNode);

    parent.removeChild(targetNode);

    // Smooth scroll to the highlighted substring
    const rect = span.getBoundingClientRect();
    window.scrollTo({
        top: rect.top + window.scrollY - 150,
        behavior: "smooth"
    });
});

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top