aliparser

sample goods

2016-01-27 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name aliparser
// @namespace Violentmonkey Scripts
// @grant none
// @description:en sample goods
// @include http://*aliexpress.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @version 0.0.1.20160127060800
// @description sample goods
// ==/UserScript==

setButton()

addEnentClick()

setIframe()

function setIframe(){
	
	var iframe = '<iframe src="http://tdom.in/www/ali/" id="iframe"></iframe>';
	$(iframe).css({'width':'100%','height':'300px'}).prependTo('body')
		
}
function addEnentClick(){
	
	$('.addButton').click(function(){
		if($(this).attr('data-it')){
			var object = {
			price:$('#product-price [item-prop=highPrice]') || $('#product-price [item-prop=highPrice]'),
			href:item.find('a.picRind').attr('href'),
			image:item.find('.picCore').attr('src'),
			id:item.find('.atc-product-id').val()
		    }
		}else
		var item = $(this).closest('li')
		var object = {
			price:item.find('.info [itemprop=price]').html(),
			href:item.find('a.picRind').attr('href'),
			image:item.find('.picCore').attr('src'),
			id:item.find('.atc-product-id').val()
		}
		win = document.getElementById('iframe').contentWindow
		win.postMessage(object,'*')

	})
	
}

function setButton(){

	var button = '<input type="button" value="ДОБАВИТЬ" class="addButton">'
	var appendTo = $('.list-item').length?'.list-item':'.product-name'
	//if(!appendTo.length) appendTo = '.list-item'
	//alert(appendTo)
	$(button).css({'position': 'absolute','top':'0px','left':'45px','z-index':'100','background':'#EA7B7B',
				  'padding':'5px 20px','border':'none','margin':'4px'}).appendTo(appendTo).attr('data-it','0')
	if(appendTo=='.product-name')
		$('.addButton').css('position','static').attr('data-it','1')
	
}