0

Greasemonkey script to solve unreadably long paragraphs problem in YDN Forum posts

When viewing various YDN Forum posts you'll occasionally run across paragraphs that are one very long line. These lines are so long their end isn't visible and the only way to read them is to copy/paste them into an editor.

The problem occurs when posts include long lines inside code blocks (see for example my Open Data Table's execute Javascript quirks? post).

One solution is for posters to make sure that code block lines are reasonably short. However, since the preview of the post looks fine, the problem isn't apparent until it's too late to fix.

Therefore, I suggest that the YDN style sheet should be updated. Changing the Yahoo YDN ydn.css file from:

CODE
.codemain {
font-family:monospace;
max-height:300px;
overflow:auto;
white-space:pre;
}

to:

CODE
.codemain {
font-family:monospace;
max-height:300px;
overflow:auto;
white-space:pre-wrap;
}

solves the problem (at least with FIrefox).

In the interim, the following greasemonkey script makes that change "on-the-fly" for all http://developer.yahoo.net/forum/* urls:
CODE
// ==UserScript==
// @name Wrap Yahoo Forum Posts
// @namespace tag:tomp2010@gmail.com,2009-08-13:YahooForum
// @description Changes Yahoo Forum codemain style to pre-wrap instead of pre
// @include http://developer.yahoo.net/forum/*
// ==/UserScript==

function addGlobalStyle(css) {
try {
var elmHead, elmStyle;
elmHead = document.getElementsByTagName('head')[0];
elmStyle = document.createElement('style');
elmStyle.type = 'text/css';
elmHead.appendChild(elmStyle);
elmStyle.innerHTML = css;
} catch (e) {
if (!document.styleSheets.length) {
document.createStyleSheet();
}
document.styleSheets[0].cssText += css;
}
}

addGlobalStyle(".codemain { white-space: pre-wrap; }");

by
2 Replies
  • Tom,

    Thanks for bringing this to our attention. I've filed a bug on this.

    Cheers,
    Robyn Tippins
    Community Manager, YDN
    0
  • And, with a bit of luck, you should find this problem is fixed now!
    0

Recent Posts

in Suggestions for YDN