aliparser

sample goods

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

  1. // ==UserScript==
  2. // @name aliparser
  3. // @namespace Violentmonkey Scripts
  4. // @grant none
  5. // @description:en sample goods
  6. // @include http://*aliexpress.com/*
  7. // @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
  8. // @version 0.0.1.20160127080800
  9. // @description sample goods
  10. // ==/UserScript==
  11.  
  12. setButton()
  13.  
  14. addEnentClick()
  15.  
  16. setIframe()
  17.  
  18. function setIframe(){
  19. var iframe = '<iframe src="http://tdom.in/www/ali/" id="iframe"></iframe>';
  20. $(iframe).css({'width':'100%','height':'300px'}).prependTo('body')
  21. }
  22. function addEnentClick(){
  23. $('.addButton').click(function(){
  24. if($(this).attr('data-it')=='1'){
  25. var object = {
  26. price: $('#product-price [itemprop=highPrice]').text() || $('#product-price [itemprop=price]').text(),
  27. href:location.href,
  28. image:$('.ui-image-viewer-thumb-wrap img').attr('src'),
  29. id:$('#hid-product-id').val()
  30. }
  31. object.price += ' '+$('#product-price [itemprop=priceCurrency]').text()
  32. }else{
  33. var item = $(this).closest('li')
  34. var object = {
  35. price:item.find('.info [itemprop=price]').html(),
  36. href:item.find('a.picRind').attr('href'),
  37. image:item.find('.picCore').attr('src'),
  38. id:item.find('.atc-product-id').val()
  39. }
  40. }
  41. win = document.getElementById('iframe').contentWindow
  42. win.postMessage(object,'*')
  43.  
  44. })
  45. }
  46.  
  47. function setButton(){
  48.  
  49. var button = '<input type="button" value="ДОБАВИТЬ" class="addButton">'
  50. var appendTo = $('.list-item').length?'.list-item':'.product-name'
  51. //if(!appendTo.length) appendTo = '.list-item'
  52. //alert(appendTo)
  53. $(button).css({'position': 'absolute','top':'0px','left':'45px','z-index':'100','background':'#EA7B7B',
  54. 'padding':'5px 20px','border':'none','margin':'4px'}).appendTo(appendTo).attr('data-it','0')
  55. if(appendTo=='.product-name')
  56. $('.addButton').css('position','static').attr('data-it','1')
  57. }