Last active
November 15, 2017 11:02
-
-
Save tuxlife/bfd94e28e0f03d354006606f48ee9d89 to your computer and use it in GitHub Desktop.
Fotograf.de Photo Order Sorter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Fotograf.de Photo Order Sorter | |
// @namespace http://tuxlife.net/ | |
// @version 0.3.3 | |
// @description Sort the pictures in the fotograf.de order | |
// @author Matthias Kerk <[email protected]> | |
// @homepage https://gist.github.com/tuxlife/bfd94e28e0f03d354006606f48ee9d89 | |
// @downloadURL https://gist.github.com/tuxlife/bfd94e28e0f03d354006606f48ee9d89/raw/fotograf.user.js | |
// @match https://app.fotograf.de/config_orders/view_order/* | |
// @require https://cdnjs.cloudflare.com/ajax/libs/tinysort/2.3.6/tinysort.js | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function () { | |
'use strict'; | |
GM_addStyle(` | |
.tuxlife-parent { | |
display: inline-block; | |
border: 2px solid #285577; | |
margin: 1px; | |
padding-left: 5px; | |
} | |
.tuxlife-parent .thumbnail { | |
display: flex; | |
} | |
.tuxlife-parent .photo-overview-filename { | |
font-size: 12px; | |
font-weight: bold; | |
padding-bottom: 0px; | |
padding-top: 0px; | |
} | |
`); | |
tinysort('#cf-photo-list>div.row-fluid>div', 'div.photo-overview-amount', 'div.photo-overview-filename'); | |
// Get all the photos | |
var photos = $('[class^=photo-overview-regular]').map(function () { | |
var decodedClass = btoa($(this).find('div.photo-overview-filename')[0].innerText + '/' + $(this).find('div.photo-overview-amount')[0].innerText).replace(/=+$/, ""); | |
$(this).addClass(decodedClass); | |
return decodedClass; | |
}); | |
// Filter only unique ones | |
var uniquePhotos = $.unique(photos); | |
console.log(uniquePhotos); | |
// Now group them | |
$(uniquePhotos).each(function (i, v) { | |
console.log(i, v); | |
var foo = $('.' + v); | |
if (jQuery('.parent-' + v).length === 0) { | |
$('.' + v).wrapAll('<div class ="tuxlife-parent parent-' + v + '">' + foo.length + ' x<div></div></div>'); | |
} else { | |
console.log('wrapped twice: ', v, jQuery('.parent-' + v).length, foo.length); | |
} | |
var $div = $('.' + v); | |
if ($div.length > 1) { | |
$div.not(':last').remove(); | |
} | |
}); | |
$('.pull-left').removeAttr("style"); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment