MicrostockGroup Sponsors


Author Topic: Request for Sean L.  (Read 3865 times)

0 Members and 1 Guest are viewing this topic.

Semmick Photo

« on: February 27, 2015, 08:39 »
0
 :)

Sean, could you quickly write a script that pulls thumbnails on Bigstock? Similar to what yo did for Canva?

http://www.bigstockphoto.com/account/commissions/downloads/

If you dont have an account and need page source code, let me know.

If you have no time, no problem !

Thanks for considering.


« Reply #1 on: February 28, 2015, 10:56 »
0
I don't have an account there, so it would be really hard.  The script isn't too insane though.  With a little time, you could probably tweak it.  It helps to have firebug so you can find the objects on the page the various things are in.

« Reply #2 on: February 28, 2015, 11:32 »
+8
can you quickly give me a foot rub too?

  ;)

kidding. well... sort of  ::)

« Reply #3 on: February 28, 2015, 14:04 »
0
Just curious, why pull thumbnails?

« Reply #4 on: February 28, 2015, 15:12 »
+2
Just curious, why pull thumbnails?

To see the sold images without having to click on the image links. That's my guess.

Semmick Photo

« Reply #5 on: March 03, 2015, 09:05 »
0
I don't have an account there, so it would be really hard.  The script isn't too insane though.  With a little time, you could probably tweak it.  It helps to have firebug so you can find the objects on the page the various things are in.
I have never coded before, but I will look at it to see if I can find anything that makes sense to me and change it. LOL

thanks,

« Reply #6 on: March 03, 2015, 10:10 »
+2
Ok, so under the function showThumbs, the first section grabs all the links on the page with the document.links function.  It then steps through them to find all the ones that match "media", since each file in the list on the page is linked to like this:
href="/media/MABDFyKV0GQ"

And it puts a reference to each of the link objects into an array - linkObjs.  So, you need to change that to pick out the image details page links.  The next bit from table through label.setAttribute just makes a new header column for the table, so you need to figure out how to find that area of the document.  I know the table has the className of "list" and is the only one with that class, so it's easy to find.

Then the
ajaxStream[0].makeRequest(myDataUrl, linkObjs[j], addThumbnailImage);
kicks off the call to each image details page, with the url to the page, a reference to the link object on the sales page, and the function to do when the call is finished.

Once the ajax finishes its magic, it runs the addThumbnailImage function, giving it all the source from the called page, and the "elementToChange" which is the reference to the link object.  It then grabs all the images on the called page with div.getElementsByTagName('img'); and steps through them one by one to see if their .id attribute is "mainImage" .  The rest just takes the linkObject reference from before, steps up into the table cell it is in, then up into the table row, and adds a new cell at the end.  Into that goes a created image pointing to the thumbnail.  The big image on the image details page is like:
https://d117r1wt3t6ahr.cloudfront.net/MABDFyKV0GQ/1/screen.jpg
And I found that the thumbnail is:
https://d117r1wt3t6ahr.cloudfront.net/MABDFyKV0GQ/1/thumbnail.jpg
So, I search and replace on the img.src string to switch to the thumb.

So, all those bits need to change based on the BS pages.  It shouldn't be hard if you go step by step.

Semmick Photo

« Reply #7 on: March 03, 2015, 10:44 »
0
Cheers Sean, appreciated. If I have a result I will post here, if not, as well. Haha.

Semmick Photo

« Reply #8 on: March 19, 2015, 17:51 »
0
Sean, been looking at this, but I think there is a challenge. You are referring to this

Quote
under the function showThumbs, the first section grabs all the links on the page with the document.links function.  It then steps through them to find all the ones that match "media", since each file in the list on the page is linked to like this:
href="/media/MABDFyKV0GQ"

So when I check the details for the BS image it seems that they generate a unique link for every image. Not sure how to pull this into the script.

Image-xxxxxxxxx

« Last Edit: March 19, 2015, 18:35 by Semmick Photo »

« Reply #9 on: March 19, 2015, 18:01 »
+1
You should be able to match on that.  Just change:
         if (str.match(/media/g))
to
         if (str.match(/image-/g))

Semmick Photo

« Reply #10 on: March 19, 2015, 18:13 »
0
Ok cool, I changed that now. and I managed to get the Thumb in the list. But the thumbs are not showing. I thin I need to change something for it to pull the thumb in there.


Semmick Photo

« Reply #11 on: March 19, 2015, 18:32 »
+2
Ok, I fixed it. YES !!!!!!!

I forgot to change the
Code: [Select]
function addThumbnailImage
Whoop


« Reply #12 on: March 19, 2015, 19:30 »
+1
Tah dah!

« Reply #13 on: March 13, 2018, 06:56 »
0
Semmick Photo said that he will post his code if he makes it work. Then he made it work but he didn't post the code. Very nice...

I'm not a coder so I can't follow Sean Locke's instructions. I tried to edit Sean Locke's script for the thumbnails on Canva but without success. Here is his script:
Code: [Select]
// ==UserScript==
// @name        CV_showThumbnail
// @namespace   canva
// @include     [url]https://www.canva.com/sales[/url]*
// @version     1
// @grant       none
// ==/UserScript==

function showThumbs() {

var linkObjs = [];
for (var j= 0;j<document.links.length;j++)
if (document.links[j].hostname===location.hostname) {
str = document.links[j].href;
if (str.match(/media/g))
linkObjs.push(document.links[j]);
}
ajaxStream = new Array();

table = document.getElementsByClassName('list')[0];
thead = table.getElementsByTagName("tr")[0];
label = document.createElement('th');
thead.appendChild(label);
label.innerHTML = "Thumb";
label.setAttribute('width', "60px");

for (var j= 0;j<linkObjs.length;j++){
myDataUrl = (linkObjs[j].href);
// make a new ajax object
ajaxStream[0] = new ajaxObj();
// pass the url from the 'a' object in the child node, and the linkObj
ajaxStream[0].makeRequest(myDataUrl, linkObjs[j], addThumbnailImage);
}

tcell = table.getElementsByTagName("td");
for (var j= 0;j<tcell.length;j++){
if (tcell[j].innerHTML == "   Multi Use   ") {
tcell[j].style.backgroundColor = "#bbffbb";
}
}

}

function addThumbnailImage(text, status, elementToChange) {
if (text == "") return;
div=document.createElement('div');
  div.innerHTML=text;
var imgs = div.getElementsByTagName('img');
for (var j= 0;j<imgs.length;j++) {
if(imgs[j].id == "mainImage") {
tr = elementToChange.parentNode.parentNode;
td = document.createElement('td');
td.setAttribute('width', "60px");

tr.appendChild(td);
img = document.createElement('img');
img.setAttribute('width', "60px");

imgSrc = imgs[j].src.replace("screen","thumbnail");
img.setAttribute('src', imgSrc);
td.appendChild(img);
return;
}
}
}

window.onload = showThumbs();

function ajaxObj() {

this.requestObject;
this.elementToChange;
this.makeRequest = function(url, elementToChange, onResponse) {
// trying to stop weird exception
if ((url=="") || (url==null)) {
if (elementToChange)
elementToChange.innerHTML = ("<center>N/A | N/A</center>");
return;
}
if (window.XMLHttpRequest) {                     // Does this browser have an XMLHttpRequest object?
this.requestObject=new XMLHttpRequest();                    // Yes -- initialize it.
} else {                                         // No, try to initialize it IE style
this.requestObject=new ActiveXObject("Microsoft.XMLHTTP");  //  Wheee, ActiveX, how do we format c: again?
}                                                // End setup Ajax.
if (this.requestObject==null) {                                // If we couldn't initialize Ajax...
      alert("Your browser doesn't support AJAX.");  // Sorry msg.                                               
      return false;                                  // Return false, couldn't set up ajax
    }
this.requestObject.onreadystatechange = function() {                      // When the browser has the request info..
    switch (this.readyState) {
case 1:
// if (elementToChange)
// elementToChange.innerHTML = ("Starting");
break;
case 2:
// if (elementToChange)
// elementToChange.innerHTML = ("Requesting");
break;
case 3:
// if (elementToChange)
// elementToChange.innerHTML = ("Processing");
break;
default:
      onResponse(this.responseText, this.readyState, elementToChange);             // Pass the response to our processing function
    }
}   
this.requestObject.open("GET",url,true);
this.requestObject.send(null);
}
}




So can somebody make the script for BS and share it here?
« Last Edit: March 13, 2018, 06:59 by stockman11 »

« Reply #14 on: March 13, 2018, 09:05 »
+2
Don't bother with Script for BS. You won't have any sales there.

« Reply #15 on: March 13, 2018, 09:17 »
0
Don't bother with Script for BS. You won't have any sales there.

That is absolutely true
+1


 

Related Topics

  Subject / Started by Replies Last post
17 Replies
9510 Views
Last post June 02, 2009, 18:17
by helix7
28 Replies
5207 Views
Last post December 01, 2012, 17:53
by qwerty
Sean Locke featured on DP

Started by Poncke v2 « 1 2 3  All » DepositPhotos

61 Replies
9995 Views
Last post June 03, 2013, 12:16
by luissantos84
7 Replies
2368 Views
Last post November 11, 2013, 15:47
by Mantis
16 Replies
3763 Views
Last post February 17, 2014, 07:11
by Silken Photography

Sponsors

Microstock Poll Results

Sponsors