aliparser (http and https)

select producy on aliexpress than post it to vk.com album

当前为 2016-09-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name aliparser (http and https)
  3. // @namespace Violentmonkey Scripts
  4. // @grant none
  5. // @description:en select producy on aliexpress than post it to vk.com album
  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.20160413080900
  10. // @description select producy on aliexpress than post it to vk.com album
  11. // ==/UserScript==
  12.  
  13. setButton()
  14.  
  15. addEnentClick()
  16.  
  17. setIframe()
  18.  
  19. function setIframe(){
  20. // var iframe = '<iframe src="http://wshost.iam.by/" id="iframe"></iframe>';
  21. //var iframe = '<iframe src="http://tdom.in/www/ali/" id="iframe"></iframe>';
  22. //var src = 'http://wshost.iam.by/'
  23. var src = 'https://tdom.in/www/ali/'
  24. $('<iframe>').css({'width':'100%','height':'410px','z-index':1000}).prependTo('body').attr('src',src).attr('id','iframe')
  25. }
  26. function addEnentClick(){
  27. $('.addButton').click(function(){
  28. var images = $('.image-nav-item img').length ?
  29. $('.image-nav-item img') : ($('.img-thumb-item img').length ?
  30. $('.img-thumb-item img') : $('.ui-image-viewer-thumb-frame img'));
  31. var imgs = new Array();
  32. for(var i=0;i<images.length;i++){
  33. imgs[i] = images[i].src.replace('.jpg_50x50','')
  34. }
  35. if($(this).attr('data-it')=='1'){
  36. var object = {
  37. price: $('[itemprop=highPrice]').text() || $('[itemprop=price]').text(),
  38. href:location.href,
  39. image:$('.ui-image-viewer-thumb-wrap img').attr('src'),
  40. id:$('#hid-product-id').val(),
  41. images: imgs
  42. }
  43. object.price += ' '+$('[itemprop=priceCurrency]').text();
  44. }else{
  45. var item = $(this).closest('li')
  46. var object = {
  47. price:item.find('.info [itemprop=price]').html(),
  48. href:item.find('a.picRind').attr('href'),
  49. image:item.find('.picCore').attr('src'),
  50. id:item.find('.atc-product-id').val(),
  51. images: imgs
  52. }
  53. }
  54. win = document.getElementById('iframe').contentWindow
  55. win.postMessage(object,'*')
  56.  
  57. })
  58. }
  59.  
  60. function setButton(){
  61.  
  62. var button = '<input type="button" value="ДОБАВИТЬ" class="addButton">'
  63. var appendTo ='.product-name'
  64. //var appendTo = $('.list-item').length?'.list-item':'.product-name'
  65. //if(!appendTo.length) appendTo = '.list-item'
  66. //alert(appendTo)
  67. $(button).css({'position': 'absolute','top':'0px','left':'45px','z-index':'100','background':'#EA7B7B',
  68. 'padding':'5px 20px','border':'none','margin':'4px'}).appendTo(appendTo).attr('data-it','0')
  69. if(appendTo=='.product-name')
  70. $('.addButton').css('position','static').attr('data-it','1')
  71. }