Script to set all types of all ready-to-upload pictures?

I’m actually uploading many hundred of classical booklet pages. It is annoying to set every single picture to the type “booklet”.

Do you know any script who could set the type for all pictures on the ready-to-upload-page before I submit it? (Changing back the few front/back covers would be easy).

And in addition:
Do you know a possibility to number such pages automatically, maybe with a starting number and increasing value? The result should be “booklet 1-2”, “booklet 3-4” for doublepages or “booklet 5”, “booklet 6”, “booklet 7” for single pages.

3 Likes

That would be nice. Guessing from the filename of the uploaded file could also be viable, but there are probably too many possible naming schemes to consider.

1 Like

@docdem: If we could use some kind of naming scheme mask, it should not be too hard to solve for some script gods .-)

I think about something like %type%_%pagenumber% (for back_03.jpg)
(not sure, why underlines are not visible in this forum software)

1 Like

Underline is a character that is used for italic, so you have to type:

%type%\_%pagenumber% (for back\_03.jpg)

In order to escape this special character transformation, which gives:

%type%_%pagenumber% (for back_03.jpg)

It is a little geeky, I know… :sunglasses:
Read more at Markdown OHP.

3 Likes

Notice that a more realistic example would be “booklet 2–3”, “booklet 4–5” and so on.
As odd pages are right and even pages left. By convention, page 1 is the cover.

Signed, mister I know everything better than everyone. :stuck_out_tongue_winking_eye:

8 Likes

[quote=“jesus2099, post:5, topic:69868”]Signed, mister I know everything better than everyone.[/quote]As long as we will see another fine NG-SELECT-ALL-TYPES-AUTOMAGICALLY-AND-GUESS-FILENAMES-FANCY-JESUS-SCRIPT you are right :sunglasses::innocent:

6 Likes

I’m not a script guru like @jesus2099 .
Until he find some time to write a really flexible and friendly Userscript, I use this workaround:

1.) Copy & paste this line of code as ONE LINE in the adressbar of your browser (tested with FireFox):

javascript:[].forEach.call(document.querySelectorAll('input[value="3"]'),function(el){if (el.checked==true) el.checked=false; else el.checked=true;});

Doublecheck if you really see the prefix «javascript:», my FireFox eat it everytime I paste it…

2.) Create a bookmark for this single line of code ***

3.) Use this bookmark on the MB /add-cover-art page with just freshly uploaded covers and it will mark every occurence of the “Booklet” type checkbox for every uploaded picture.

4.) You can easily change the type of checkbox to be activated by changing the number follwing "value="
The # 1 is the Front Cover, # 2 the Back Cover, # 3 the Booklet and so on up to 13 for Watermark.

Hint:
*** if you get a warning about «…preventing social engineering attacks…» you may have installed NoScript. It’s up to you to create the bookmark directly or deactivate NoScript for this step.
If you see your bookmark with the above line, you can re-activate NoScript and the line works fine.

1 Like

Just for information, I had create a ticket for this feature.

But I don’t really expect to have time to do it very soon, unfortunately.

1 Like

Just to let you know:
It seems that at least in FireFox and Google Chrome the checkboxes for “booklet” are set correctly with the above script and they are visible as expected.
BUT: If you send such a page to the MB server, all the covers with such a automatically set checkbox results in a cover WITHOUT any type.

I don’t know why there should be a difference setting the checkmarks manually or with a script.
@jesus2099: I still hope you can find some spare time and write another wonderful Greasemonkey script. :christmas_tree:

1 Like

Because of how the MBS page are built using some JavaScript library (knockout, AngularJS, something like that), you have to despatch the change event after having set your value on the input.

Like in my scripts (for which I made a utility sendEvent function), you can do:

var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
el.dispatchEvent(event);

I have not tested your bookmarklet, but it may do the trick.

3 Likes

Thank you for your prompt reply, jesus2099!
You are right. Thanks to your hint I have found this (even easier) solution for my bookmarklet:

javascript:[].forEach.call(document.querySelectorAll('input[value="3"]'), function(el) {el.click();});

The .click method toggles the actual state of every occurence of a “boooklet”-checkbox automatically and seems to do all the necessary steps.

This method can be used to execute a click on an element as if the user manually clicked on it.

2 Likes

It is now possible to enter the number for the checkbox you want to activate.
No need to change the bookmarklet-code anymore:
javascript: var val=prompt("# of Checkbox to activate or deactivate \n(Front=1, Back=2, Booklet=3...)",""); [].forEach.call(document.querySelectorAll('input[value="'+val+'"]'), function(el) {el.click();});

3 Likes