Topic Wiki

UPDATE:
@JoeyShmoe did a great job creating a Chrome Extension and a Firefox Extension to save us all the hassle of setting up a bookmarklet. The extension will place a button on any Amazon product page. When you click the button it will copy a link to your clipboard, which you can paste into any DDF post. The post will then contain the product title, image, and a working link to the product.

Thanks @JoeyShmoe!

---

For anyone who doesn't want to install a browser extension, read below how to set up the bookmarklet:

Here is a bookmarklet that will make a DD link from any amazon item page, and format it with the title and an image so you can paste it into a DDF post.

Example:

Little Tikes Rocking Horse Magenta ($34.07)



(Not sure what a bookmarklet is? Read more about them in this thread: http://forums.dansdeals.com/index.php?topic=61269.5.)

Here's how to install the bookmarklet:

1. If you don't currently see a row of bookmarks on the top of your browser, you will need to show the bookmarks bar.
- In Chrome, click the 3 vertical dots at the top right of your screen, click Settings, and click Always Show the Bookmarks Bar.
- In Firefox, click the 3 horizontal lines at the top right of your screen, and click Customize. Then click Show/Hide Toolbars (bottom left of your screen) and check off the Bookmarks Toolbar.

2. Copy the following code. (To do so, click the SELECT button and then press control-c on your keyboard.)
Code: [Select]
javascript: (function() {
    var pattern = new RegExp("(https:\/\/www.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*|(https:\/\/smile.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*", "i"),
        match = location.href.match(pattern),
        image = document.getElementById('landingImage').src;
    var price = "";
    if (document.getElementById('priceblock_dealprice') !== null) {
        price = " (" + document.getElementById('priceblock_dealprice').innerHTML + ")";
    } else if (document.getElementById('priceblock_ourprice') !== null) {
        price = " (" + document.getElementById('priceblock_ourprice').innerHTML + ")";
    }
    var URL = (match[1] !== undefined) ? match[1] + "dp/" + match[3] + "/?tag=cl03f-20&smid=ATVPDKIKX0DER" : match[4] + "dp/" + match[6] + "/?tag=cl03f-20&smid=ATVPDKIKX0DER";
    var result = "[url=" + URL + "]" + document.title + price + "[/url][br][br][url=" + URL + "][img]" + image + "[/img][/url]";
    if (document.execCommand('copy') !== false) {
        var ddLink = document.createElement('span'),
            range = document.createRange();
        ddLink.id = "ddLink";
        ddLink.innerText = result;
        document.body.appendChild(ddLink);
        range.selectNode(document.getElementById('ddLink'));
        window.getSelection().addRange(range);
        document.execCommand('copy');
        document.getElementById('ddLink').remove();
        setTimeout(function() {
            alert('DD link copied to clipboard...')
        }, 1000);
    } else {
        window.prompt("Press control-c", result);
    }
    void(0);
})()

3. To create the bookmarklet, right click on your bookmarks bar and click "Add page" (if you're in Chrome) or "New bookmark" (Firefox).

For the Name, enter whatever you want (eg: Dan Amazon link), and for the URL/Location enter the code above, which you already copied.

4. Click Save (Chrome) or Add (Firefox)

To use the bookmarklet, simply click on the bookmark you created (in step 3) when you are on any amazon product page. Follow the prompts (you may need to press control-c to copy what pops up), and then paste it into any DDF post.

Enjoy!

Disclaimer: The code might need a little tweaking, so let me know if you have a link that it doesn't work on. If there are any changes I will update the wiki.

Author Topic: Amazon DD Bookmarklet: Have Chrome Make A DDF Friendly Link On Amazon  (Read 7287 times)

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
Weird! @JoeyShmoe any idea why? It seems to work with the original bookmarklet, but not with our final version.
I'll take a look next time I'm at my desk
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline myi

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Feb 2015
  • Posts: 8327
  • Total likes: 271
  • DansDeals.com Hat Tips 126
    • View Profile
  • Location: brklyn/Israel
Weird! @JoeyShmoe any idea why? It seems to work with the original bookmarklet, but not with our final version.
I'll take a look next time I'm at my desk
thanks for your time. You guys are great!
Don't try to be someone else , be who you are because everyone else is taken.

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
Weird! @JoeyShmoe any idea why? It seems to work with the original bookmarklet, but not with our final version.
Fixed, code below. Interesting thing is that in the link you quoted the price isn't called "Price", rather "With Deal", and the id for field is also not priceblock_ourprice (which is what you have) rather priceblock_dealprice. That's why it was erroring, because the Price field was null. It also only worked with your original code that didn't include the price. I added a conditional statement that should only put in the price if one of the two above versions isn't null, otherwise there won't be a price included (I can add scenarios as we find them)

Code: [Select]
javascript:(function(){
  var pattern = new RegExp("(https:\/\/www.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*|(https:\/\/smile.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*", "i"),
      match = location.href.match(pattern),
      image = document.getElementById('landingImage').src;
  var price = "";
  if(document.getElementById('priceblock_dealprice') !== null) {
    price = " [b](" + document.getElementById('priceblock_dealprice').innerHTML + ")[/b]";
  } else if(document.getElementById('priceblock_ourprice') !== null) {
    price = " [b](" + document.getElementById('priceblock_ourprice').innerHTML + ")[/b]";
  }
  var URL = (match[1] !== undefined) ? match[1] + "dp/" + match[3] +"/?tag=cl03f-20&smid=ATVPDKIKX0DER": match[4] + "dp/" + match[6] +"/?tag=cl03f-20&smid=ATVPDKIKX0DER";
  var result = "[url="+URL+"]"+document.title + price + "[/url][br][br][url="+URL+"][img]"+image+"[/img][/url]";
  if(document.execCommand('copy') !== false) {
    var ddLink = document.createElement('span'),
        range = document.createRange();
    ddLink.id = "ddLink";
    ddLink.innerText = result;
    document.body.appendChild(ddLink);
    range.selectNode(document.getElementById('ddLink'));
    window.getSelection().addRange(range);
    document.execCommand('copy');
    document.getElementById('ddLink').remove();
    setTimeout(function() {
      alert('DD link copied to clipboard...')
    }, 1000);
  } else {
    window.prompt("Press control-c",result);
  } void(0);
})()

thanks for your time. You guys are great!
My pleasure :)
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline etech0

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Dec 2013
  • Posts: 8472
  • Total likes: 116
  • DansDeals.com Hat Tips 1
    • View Profile
  • Location: not lakewood
  • Programs: DDF
Fixed, code below. Interesting thing is that in the link you quoted the price isn't called "Price", rather "With Deal", and the id for field is also not priceblock_ourprice (which is what you have) rather priceblock_dealprice. That's why it was erroring, because the Price field was null. It also only worked with your original code that didn't include the price. I added a conditional statement that should only put in the price if one of the two above versions isn't null, otherwise there won't be a price included (I can add scenarios as we find them)

Code: [Select]
javascript:(function(){
  var pattern = new RegExp("(https:\/\/www.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*|(https:\/\/smile.amazon.com\/).*([dg]p\/)(?:product\/)?(..........).*", "i"),
      match = location.href.match(pattern),
      image = document.getElementById('landingImage').src;
  var price = "";
  if(document.getElementById('priceblock_dealprice') !== null) {
    price = " [b](" + document.getElementById('priceblock_dealprice').innerHTML + ")[/b]";
  } else if(document.getElementById('priceblock_ourprice') !== null) {
    price = " [b](" + document.getElementById('priceblock_ourprice').innerHTML + ")[/b]";
  }
  var URL = (match[1] !== undefined) ? match[1] + "dp/" + match[3] +"/?tag=cl03f-20&smid=ATVPDKIKX0DER": match[4] + "dp/" + match[6] +"/?tag=cl03f-20&smid=ATVPDKIKX0DER";
  var result = "[url="+URL+"]"+document.title + price + "[/url][br][br][url="+URL+"][img]"+image+"[/img][/url]";
  if(document.execCommand('copy') !== false) {
    var ddLink = document.createElement('span'),
        range = document.createRange();
    ddLink.id = "ddLink";
    ddLink.innerText = result;
    document.body.appendChild(ddLink);
    range.selectNode(document.getElementById('ddLink'));
    window.getSelection().addRange(range);
    document.execCommand('copy');
    document.getElementById('ddLink').remove();
    setTimeout(function() {
      alert('DD link copied to clipboard...')
    }, 1000);
  } else {
    window.prompt("Press control-c",result);
  } void(0);
})()
My pleasure :)
Interesting! Thanks for figuring it out!!
Workflowy. You won't know what you're missing until you try it.

Offline myi

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Feb 2015
  • Posts: 8327
  • Total likes: 271
  • DansDeals.com Hat Tips 126
    • View Profile
  • Location: brklyn/Israel
Curios to know as I never tried it, as to what happens when it's a ss item? (yes I'm not near a computer). ;)
Don't try to be someone else , be who you are because everyone else is taken.

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
Curios to know as I never tried it, as to what happens when it's a ss item? (yes I'm not near a computer). ;)
Interesting question, this gets the main price that's directly under the title
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline etech0

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Dec 2013
  • Posts: 8472
  • Total likes: 116
  • DansDeals.com Hat Tips 1
    • View Profile
  • Location: not lakewood
  • Programs: DDF
Interesting question, this gets the main price that's directly under the title
Good point. Maybe when I have a few minutes I'll see if we can pull in both.
Workflowy. You won't know what you're missing until you try it.

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
Curios to know as I never tried it, as to what happens when it's a ss item? (yes I'm not near a computer). ;)
Good point. Maybe when I have a few minutes I'll see if we can pull in both.
I just tested it and it shows the regular price. It might be a bit complicated especially with the 5%/15% prices...
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline myi

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Feb 2015
  • Posts: 8327
  • Total likes: 271
  • DansDeals.com Hat Tips 126
    • View Profile
  • Location: brklyn/Israel
I just tested it and it shows the regular price. It might be a bit complicated especially with the 5%/15% prices...
Obviously it will pull what ever the page shows, whether you have 5+ items or not? 
Don't try to be someone else , be who you are because everyone else is taken.

Offline etech0

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Dec 2013
  • Posts: 8472
  • Total likes: 116
  • DansDeals.com Hat Tips 1
    • View Profile
  • Location: not lakewood
  • Programs: DDF
Obviously it will pull what ever the page shows, whether you have 5+ items or not?
The complicated part is that amazon doesn't display both prices on the page, but just because the OP is getting 15% (or 5%) off, doesn't mean that everyone else will.
Workflowy. You won't know what you're missing until you try it.

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
The complicated part is that amazon doesn't display both prices on the page, but just because the OP is getting 15% (or 5%) off, doesn't mean that everyone else will.
That, and the fact that even if you tried to access the discounts, they're in very generic fields. I have an idea I want to explore today
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline etech0

  • Dansdeals Lifetime Presidential Platinum Elite
  • *********
  • Join Date: Dec 2013
  • Posts: 8472
  • Total likes: 116
  • DansDeals.com Hat Tips 1
    • View Profile
  • Location: not lakewood
  • Programs: DDF
Stay tuned everyone, something really cool is in the works!
Workflowy. You won't know what you're missing until you try it.

Offline stooges44

  • Dansdeals Presidential Platinum Elite
  • ********
  • Join Date: Jan 2017
  • Posts: 3027
  • Total likes: 112
  • DansDeals.com Hat Tips 110
    • View Profile
Stay tuned everyone, something really cool is in the works!

Shows you the price history as well? That would be incredible!

Offline JoeyShmoe

  • Dansdeals Platinum Elite + Lifetime Gold Elite
  • ******
  • Join Date: Nov 2014
  • Posts: 952
  • Total likes: 33
  • DansDeals.com Hat Tips 0
  • Gender: Male
    • View Profile
  • Location: Lakewood
Hey all!

I decided to take @etech0's hard work to the next level and make a Chrome Extension (Firefox extension in the works already). It's very much still in Alpha stages, so I'll appreciate any feedback y'all can give me :)

The link is https://chrome.google.com/webstore/detail/dansdeals-amazon-link-gen/lddihjecngahaibhimfijbikbkoajhgi, see screenshot attached to see how it works. All it does is add a button under the price of the item which when clicked copies the code to your clipboard.

Thanks @etech0 for all of the help!! I couldn't have done this without you starting this :)
« Last Edit: June 23, 2017, 11:36:29 AM by JoeyShmoe »
DDF A-Z Link Extension
Chrome
Firefox
Info

Offline username

  • Dansdeals Presidential Platinum Elite
  • ********
  • Join Date: Jul 2008
  • Posts: 3588
  • Total likes: 121
  • DansDeals.com Hat Tips 9
  • Gender: Male
    • View Profile
  • Location: C Heights
  • Programs: ┌──────────────────┐ │───> Ữ₴ΣЯИΛΜӘ <─── │ └──────────────────┘
T h a n k s  D a n !