lumberJocks projects images downloader

Able you to download LumberJocks projects image in large size.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name	lumberJocks projects images downloader
// @version 1.0.1
// @copyright	albworkshop.fr
// @namespace  http://lumberjocks.com/
// @description Able you to download LumberJocks projects image in large size.
// @include http://lumberjocks.com/projects/*
// @grant	none
// ==/UserScript==

/** Changelog ---------------

1.0.1 (2014-12-28)
		- using the sidebar to display download links
		- adding style & title to identify links
		- publish this script on internet (http://www.albworkshop.fr)

*/

function createImagesLinks() {
	//console.debug('executing lumberJock projects image grabber');

	var BASEPATH = 'http://lumberjocks.com/assets/pictures/projects/';
	var main = document.getElementById('project-sidebar');
	if(main != null) {

		var clearer = document.createElement('div');
		clearer.style.clear = "both";
		main.appendChild(clearer);
		
		var title = document.createElement('h2');
		title.innerHTML = "Download project images"
		main.appendChild(title);

		var newDiv = document.createElement('div');
		newDiv.setAttribute('class', 'sidebar-box');
		main.appendChild(newDiv);

		var imgLinks = document.getElementsByClassName('thumbs')[0].childNodes;
		console.debug('imgLinks :', imgLinks);

		var pathStrings = '';
		for(var i = 0; i<imgLinks.length; i++) {
			var a = imgLinks[i];

			if(a != undefined && a.tagName == "A") {
				console.debug('node index:',i, ' ', a);
//				var onclickStr = a.onclick.toString();
				var onclickStr = a.getAttribute('onclick');
				console.debug('onclickStr :', onclickStr);
				var matches = onclickStr.match(/(projects\/)([0-9]+)(-438x)/);
				if(matches != null) {
					pathStrings += '<a href="' + BASEPATH + matches[2] + '.jpg' + '">image ' + i + '</a><br /> ';
				}
			}
		}

		newDiv.innerHTML = pathStrings + ' <br />';
	} else {
		console.debug('rien a faire');
	}
}


createImagesLinks();