aliparser with partner link (https)

select producy on aliexpress then post it to vk.com album with partner link

  1. // ==UserScript==
  2. // @name aliparser with partner link (https)
  3. // @namespace Violentmonkey Scripts
  4. // @grant none
  5. // @description:en select producy on aliexpress then post it to vk.com album with partner link
  6. // @include http://*aliexpress.com/*
  7. // @include https://*aliexpress.com/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
  9. // @version 0.0.1.20160915080900
  10. // @description select producy on aliexpress then post it to vk.com album with partner link
  11. // ==/UserScript==
  12.  
  13. setButton()
  14.  
  15. addEventClick()
  16.  
  17. setIframe()
  18.  
  19. function setIframe(){
  20. var src = 'https://tdom.in/www/ali2/',
  21. display = localStorage.getItem('aliparse_visible') == 'true' ?'block':'none';
  22. $('<iframe>').css({display: display,width:'100%','height':'410px','z-index':99999}).prependTo('body').attr('src',src).attr('id','iframe')
  23.  
  24. $('<div id="aliparse_wrapper_toggler">ALIPARSER <small>свернуть / развернуть</small></div> ')
  25. .insertBefore('#iframe').css({
  26. padding:'10px',
  27. margin:0,
  28. color:'#fff',
  29. background:'#e62e04',
  30. cursor:'pointer',
  31. })
  32. .click(function(){
  33. $('#iframe').slideToggle('slow', function(){
  34. localStorage.setItem('aliparse_visible',$('#iframe').is(':visible'));
  35. })
  36. });
  37. }
  38. function addEventClick(){
  39. $('.addButton').click(function(){
  40. var images = $('.image-nav-item img').length ?
  41. $('.image-nav-item img') : ($('.img-thumb-item img').length ?
  42. $('.img-thumb-item img') : $('.ui-image-viewer-thumb-frame img'));
  43. var imgs = new Array();
  44. for(var i=0;i<images.length;i++){
  45. imgs[i] = images[i].src.replace('.jpg_50x50','')
  46. }
  47. if($(this).attr('data-it')=='1'){
  48. var object = {
  49. price: $('[itemprop=lowPrice]').text() || $('[itemprop=price]').text(),
  50. href:location.href,
  51. desc : $('.product-name').text(),
  52. image:$('.ui-image-viewer-thumb-wrap img').attr('src'),
  53. id:$('#hid-product-id').val(),
  54. images: imgs
  55. }
  56. object.price += ' '+$('[itemprop=priceCurrency]').text();
  57. }else{
  58. var item = $(this).closest('li')
  59. var object = {
  60. price:item.find('.info [itemprop=price]').html(),
  61. href:item.find('a.picRind').attr('href'),
  62. image:item.find('.picCore').attr('src'),
  63. id:item.find('.atc-product-id').val(),
  64. images: imgs
  65. }
  66. }
  67. win = document.getElementById('iframe').contentWindow
  68. win.postMessage(object,'*')
  69.  
  70. })
  71. }
  72.  
  73. function setButton(){
  74.  
  75. var button = '<input type="button" value="добавить" class="addButton">'
  76. var appendTo ='.product-name'
  77. //var appendTo = $('.list-item').length?'.list-item':'.product-name'
  78. //if(!appendTo.length) appendTo = '.list-item'
  79. //alert(appendTo)
  80. $(button).css({'position': 'absolute','top':'0px','left':'45px','z-index':'100','background':'#494',
  81. 'padding':'5px 20px','border':'none','margin':'4px','color':'#fff',borderRadius:'3px', boxShadow:'rgba(100,200,100,.7) 2px 2px 7px'}).appendTo(appendTo).attr('data-it','0')
  82. if(appendTo=='.product-name')
  83. $('.addButton').css('position','static').attr('data-it','1')
  84. }