aliparser

sample goods

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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.20160326080900
// @description sample goods
// ==/UserScript==

setButton()

addEnentClick()

setIframe()

function setIframe(){
	var iframe = '<iframe src="http://scr.wshost.iam.by/ali/" id="iframe"></iframe>';
	//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(){
		var images = $('.image-nav-item img').length?$('.image-nav-item img'):$('.ui-image-viewer-thumb-frame img');
		var imgs = new Array();
		//alert(images.length)
		for(var i=0;i<images.length;i++){
			imgs[i] = images[i].src.replace('.jpg_50x50','')
		}
		if($(this).attr('data-it')=='1'){
			var object = {
			price: $('#product-price [itemprop=highPrice]').text() || $('#product-price [itemprop=price]').text(),
			href:location.href,
			image:$('.ui-image-viewer-thumb-wrap img').attr('src'),
			id:$('#hid-product-id').val(),
			images: imgs
		    }
			object.price += ' '+$('#product-price [itemprop=priceCurrency]').text()
		}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(),
			images: imgs
			}
		}
		win = document.getElementById('iframe').contentWindow
		win.postMessage(object,'*')

	})
	
}

function setButton(){

	var button = '<input type="button" value="ДОБАВИТЬ" class="addButton">'
	var appendTo ='.product-name'
	//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')
	
}