aliparser

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

  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.20160121050800
  9. // ==/UserScript==
  10.  
  11. setButton()
  12.  
  13. addEnentClick()
  14.  
  15. setIframe()
  16.  
  17. function setIframe(){
  18. var iframe = '<iframe src="http://tdom.in/www/ali" id="iframe"></iframe>';
  19. $(iframe).css({'width':'100%','height':'300px'}).prependTo('body')
  20. }
  21. function addEnentClick(){
  22. $('.addButton').click(function(){
  23. var item = $(this).closest('li')
  24. var object = {
  25. price:item.find('.info [itemprop=price]').html(),
  26. href:item.find('a.picRind').attr('href'),
  27. image:item.find('.picCore').attr('src'),
  28. id:item.find('.atc-product-id').val()
  29. }
  30. win = document.getElementById('iframe').contentWindow
  31. win.postMessage(object,'*')
  32.  
  33. })
  34. }
  35.  
  36. function setButton(){
  37.  
  38. var button = '<input type="button" value="ДОБАВИТЬ" class="addButton">'
  39. var appendTo = $('.right-block.util-clearfix').length?'.right-block.util-clearfix':'.list-item'
  40. $(button).css({'position': 'absolute','top':'0px','left':'45px','z-index':'100','background':'#EA7B7B',
  41. 'padding':'5px 20px','border':'none','margin':'4px'}).appendTo(appendTo)
  42. }