LESSWRONG
LW

PracticalSite Meta
Frontpage

44

Userscript to always show LW comments in context vs at the top

by Vlad Sitalo
21st Nov 2023
1 min read
8

44

PracticalSite Meta
Frontpage

44

Userscript to always show LW comments in context vs at the top
13lc
1Vlad Sitalo
1Vlad Sitalo
2jefftk
1Vlad Sitalo
5jefftk
1Vlad Sitalo
2jefftk
New Comment
8 comments, sorted by
top scoring
Click to highlight new comments since: Today at 11:33 AM
[-]lc2y139

Whenever I browse to a comment link I'm just waiting until the page loads so that I can use the See Context button.

Reply
[-]Vlad Sitalo2y10

Oh, that actually suggests a slightly better version, that won't reload the page. Updated the post!

Reply
[-]Vlad Sitalo2y10

Uh nvm, that doesn't work reliably bc of the comment lazy loading 🤔

Reply
[-]jefftk2y20

I wish I could use this on mobile...

I don't understand why the non-context display option exists.

(Except for a bug where "see in context" doesn't work when the parent is collapsed)

Reply
[-]Vlad Sitalo2y10

If you use android: https://kiwibrowser.com/ supports extensions!

Reply
[-]jefftk2y50

When you use a browser you're putting an enormous amount of trust in it's manufacturer to get security right, and I don't have that level of trust for most vendors.

Reply
[-]Vlad Sitalo2y10

That's fair. I believe kiwi is a fork of chrome that is kept up to date with a set of patches applied on top fwiw.

Reply
[-]jefftk2y20

How up to date? Chrome security patches are very often followed by reverse engineering and exploitation, so you need to be very prompt.

(Yes, this means I don't trust any browsers except Chrome, Firefox, Safari)

Reply
Moderation Log
More from Vlad Sitalo
View more
Curated and popular this week
8Comments

The out of context top-level display of comments when I navigate to them always bothered me, but up until recently I haven't realized there is a way to go to the actual comment via a simple URL change. 

From https://www.lesswrong.com/posts/<postid>/?commentId=<commentid>
To https://www.lesswrong.com/posts/<postid>#<commentid>

Here is a quick gpt4 generated userscript that does this. 

// ==UserScript==
// @name         Always show in-context comments
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Redirect from '?commentId=' format to '#'
// @author       Vlad Sitalo
// @match        https://www.lesswrong.com/*
// @grant        none
// ==/UserScript==


(function() {
    'use strict';

    var checkAndRedirect = function() {
        var url = window.location.href;
        if(url.includes("?commentId=")){
            var newUrl = url.split("?commentId=").join("#");
            window.location.href = newUrl;
        }
    };

    // Run on page load
    checkAndRedirect();

    // Run on URL change
    var pushState = history.pushState;
    history.pushState = function() {
        pushState.apply(history, arguments);
        checkAndRedirect();
    };

    var replaceState = history.replaceState;
    history.replaceState = function() {
        replaceState.apply(history, arguments);
        checkAndRedirect();
    };

    window.addEventListener('popstate', checkAndRedirect);
})();