r/linux • • Mar 21 '16

"Visual blindness" of Linux programmers

I mean, you can hardly see any screenshots on Github or other pages at all. I would say 90% of the projects lack any screenshot, animated gif or, Penguin forbid, video.

And this goes to not only GUI programs but TUI programs too. I mean, making a screenshot on Linux in 2016 is a trivial thing and still the visual blindness and ignorance of the visual presentation is... very big ;)

Please, even if you are "visually blind" programmer, consider uploading at least one screenshot per your program, even if it is a text based program. The others aka "unblinders" will appreciate that. Thanks.

1.3k Upvotes

476 comments sorted by

View all comments

Show parent comment

6

u/expert-at-nothing Mar 22 '16 edited Mar 22 '16

Here is how you fix that client-side:

// ==UserScript==
// @name           *-look.org thumbnail enlarger
// @author         Nigglypuff
// @namespace      meta.ironi.st
// @include        http://gnome-look.org*
// @include        http://*.gnome-look.org*
// @include        http://kde-look.org*
// @include        http://*.kde-look.org*
// @include        http://xfce-look.org*
// @include        http://*.xfce-look.org*
// @include        http://box-look.org*
// @include        http://*box-look.org*
// ==/UserScript==

var thumbnailPath = '/CONTENT/content-m1/m',
	fullSizePath = '/CONTENT/content-pre1/';

function fixImageExtension(url, callback) {
	// remove extension from original url
	url = url.slice(0, -3);
	
	var extensions = ['jpg', 'gif', 'png'];
	
	function tryNextExtension(){
		var extension = extensions.shift();
		
		if (extension) {
			testImageExists(url + extension, function (exists) {
				if (exists) {
					callback(url + extension);
				} else {
					tryNextExtension();
				}
			});
		} else {
			callback(null);
		}
	};
	
	tryNextExtension();
	
};

function testImageExists(url, callback) {
	var testImg = document.createElement('img');
	
	testImg.addEventListener('load', function () {
		callback(true);
	}, false);
	
	testImg.addEventListener('error', function () {
		callback(false);
	}, false);
	
	testImg.src = url;
};

[].forEach.call(document.images, function(img) {
	var thumbnailName = img.src.split(thumbnailPath)[1];
	
	if (thumbnailName) {
		img.style.maxWidth = '300px';
		fixImageExtension(fullSizePath + thumbnailName, function(fixedUrl) {
			if (fixedUrl) img.src = fixedUrl;
		});
	}
});

Personally, I add the following for a little more UI cleanup:

function getElementByXpath(path) {
  return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}

var myEl = getElementByXpath('/html/body/table[2]/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[5]');
myEl.style.display = 'none';

var myEl = getElementByXpath('/html/body/table[2]/tbody/tr/td[2]/table/tbody/tr[2]/td/table/tbody/tr/td[4]');
myEl.style.display = 'none';