aliparser (http and https)

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

2018-04-05 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name aliparser (http and https)
// @namespace Violentmonkey Scripts
// @grant none
// @description:en select producy on aliexpress then post it to vk.com album
// @include *aliexpress.com*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @version 0.1.0.201804051
// @description select producy on aliexpress then post it to vk.com album
// ==/UserScript==

setButton();

addEventClick();

setIframe();

function setIframe(){
	// var iframe = '<iframe src="http://wshost.iam.by/" id="iframe"></iframe>';
	//var iframe = '<iframe src="http://tdom.in/www/ali/" id="iframe"></iframe>';
	//var src = 'http://wshost.iam.by/'
	var src = 'https://kramarenko.niro.biz/ali_parser/';
    if(document.parent !== document.self){
        throw new Error('not main window');
    }
	$('<iframe>').css({'width':'100%','height':'410px','z-index':1000}).prependTo('body:eq(0)').attr('src',src).attr('id','iframe');

}
function addEventClick(){

	$('.addButton').click(function(){
		var images = $('.image-nav-item img').length ?
			$('.image-nav-item img') : ($('.img-thumb-item img').length ?
									  $('.img-thumb-item img') : $('.ui-image-viewer-thumb-frame img'));
		var imgs = [];
		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: $('[itemprop=highPrice]').text() || $('[itemprop=price]').text(),
			href:location.href,
			image:$('.ui-image-viewer-thumb-wrap img').attr('src'),
			id:$('#hid-product-id').val(),
			images: imgs,
		    };
			object.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');

}