// ==UserScript==
// @name Aliexpress Shopping Card Editor
// @name:ru Редактор корзины Aliexpress
// @version 1.3.5
// @description Adds support to select items from the cart before ordering
// @description:ru Добавляет возможность выбирать товары из корзины перед заказом
// @author DeNcHiK3713
// @namespace https://greasyfork.org/users/174390
// @match *://*.aliexpress.com/*
// @run-at document-end
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @grant GM_setClipboard
// @grant GM_openInTab
// ==/UserScript==
var cookie = false;
if (document.cookie.match('affiliateKey[%a-fA-F0-9]+22jqf2Rf6')) {
cookie = true;
}
var Language = GM_config.getValue('Language', navigator.language.slice(0,2));
var cashback = GM_config.getValue('cashback', false);
if (cashback && !cookie) {
location.href = 'http://shopeasy.by/redirect/cpa/o/o8barzkbzmcxdmf3n4as8uo2sv1uypnl/?to=' + encodeURIComponent(location.href);
}
var shoppingcart = false;
if (location.host === 'shoppingcart.aliexpress.com') {
shoppingcart = true;
}
if (shoppingcart) {
var accounting_min_script = document.createElement('script');
accounting_min_script.setAttribute('src', 'https://openexchangerates.github.io/accounting.js/accounting.min.js');
(document.body || document.head || document.documentElement).appendChild(accounting_min_script);
var money_min_script = document.createElement('script');
money_min_script.setAttribute('src', 'https://openexchangerates.github.io/money.js/money.min.js');
(document.body || document.head || document.documentElement).appendChild(money_min_script);
var aliexpress_shopping_card_editor_library_script = document.createElement('script');
aliexpress_shopping_card_editor_library_script.setAttribute('src', 'https://greasyfork.org/scripts/39395-aliexpress-shopping-card-editor-library/code/Aliexpress%20Shopping%20Card%20Editor%20Library.js?version=261706');
(document.body || document.head || document.documentElement).appendChild(aliexpress_shopping_card_editor_library_script);
}
var dictionary = {};
var fields = {};
function ChangeLanguage() {
'use strict';
switch (Language) {
case 'en':
dictionary = {
Settings: 'Settings',
title: 'Aliexpress Shopping Card Editor Settings',
ChooseLanguage: 'Choose Language',
SaveButton: 'Save',
CloseButton: 'Close',
OKButton: 'OK',
CancelButton: 'Cancel',
SelectAllButton: 'Select All',
DeSelectAllButton: 'Deselect All',
RemoveSelected: 'Remove Selected',
RestoreLabel: 'Restore default settings',
DonateLabel: 'Donate',
DonateCopy: 'Copy',
DonateCopied: 'Copied!',
CashbackLabel: 'Allow the author of this script to receive your cashback',
CashbackButton: 'Create your cashback account',
};
break;
case 'ru':
dictionary = {
Settings: 'Настройки',
title: 'Настройки редактора корзины Aliexpress',
ChooseLanguage: 'Выберете язык',
SaveButton: 'Сохранить',
CloseButton: 'Закрыть',
OKButton: 'Ок',
CancelButton: 'Отмена',
SelectAllButton: 'Выделить все',
DeSelectAllButton: 'Снять выделение',
RemoveSelected: 'Удалить выделеное',
RestoreLabel: 'Восстановить стандартные настройки',
DonateLabel: 'Пожертвовать',
DonateCopy: 'Скопировать',
DonateCopied: 'Скопировано!',
CashbackLabel: 'Разрешить автору этого скрипта получать ваш кэшбэк',
CashbackButton: 'Создайте свой кэшбэк аккаунт',
};
break;
}
fields = {
'Language': {
'label': dictionary.ChooseLanguage,
'type': 'select',
'options': ['en', 'ru'],
'save': false
},
'DonateLabel': {
'label': dictionary.DonateLabel,
'type': 'select',
'options': ['WMB: B117755765458', 'WMR: R335930872834', 'WME: E178919901149', 'WMX: X280601043398', 'BTC: 1J7J5k9FfV9SVPkPkDZ1dgEtmmDKgrBJ7o'],
'default': 'WMB: B117755765458',
'save': false
},
'DonateCopy': {
'label': dictionary.DonateCopy,
'type': 'button',
'click': function() {
GM_setClipboard(GM_config.fields.DonateLabel.toValue().slice(5), 'text');
alert(dictionary.DonateCopied);
},
'save': false
},
'CashbackCheckbox': {
'label': dictionary.CashbackLabel,
'type': 'checkbox',
'save': false
},'CashbackButton': {
'label': dictionary.CashbackButton,
'type': 'button',
'click': function() {
GM_openInTab('http://epnclick.ru/redirect/cpa/o/p625nuw7cj37ze0ixz5ilhcenq7205a1/', false);
},
'save': false
}
};
}
function ChangeButtons() {
var bp_banner = document.getElementsByClassName('bp-banner-new')[0];
bp_banner.innerHTML = '<button onclick="change_all(true);">'+dictionary.SelectAllButton+'</button><button onclick="change_all(false);">'+dictionary.DeSelectAllButton+'</button>';
document.getElementsByClassName('bottom-info-left')[0].getElementsByTagName('form')[0].getElementsByTagName('a')[0].textContent = dictionary.RemoveSelected;
}
ChangeLanguage();
if (shoppingcart) {
ChangeButtons();
}
GM_config.init({
'id': 'AliexpressEditorConfig',
'title': dictionary.title,
'fields': fields,
'events': {
'init': function() {
'use strict';
GM_config.fields.Language.value = Language;
GM_config.fields.CashbackCheckbox.value = cashback;
},
'open': function(doc) {
'use strict';
var config = this;
doc.getElementById(config.id + '_saveBtn').textContent = dictionary.SaveButton;
doc.getElementById(config.id + '_closeBtn').textContent = dictionary.CloseButton;
doc.getElementById(config.id + '_resetLink').textContent = dictionary.RestoreLabel;
},
'save': function(values) {
'use strict';
for (var id in values) {
switch (id) {
case 'Language':
if (values[id] !== Language) {
Language = values[id];
ChangeLanguage();
if (shoppingcart) {
ChangeButtons();
}
GM_config.fields.Language.value = Language;
GM_config.init({
'id': 'AliexpressEditorConfig',
'title': dictionary.title,
'fields': fields
});
GM_config.close();
GM_config.open();
GM_config.setValue('Language', Language);
}
break;
case 'CashbackCheckbox':
if (values[id] !== cashback) {
cashback = values[id];
GM_config.fields.CashbackCheckbox.value = cashback;
GM_config.setValue('cashback', cashback);
if (cashback && !cookie) {
location.href = 'http://shopeasy.by/redirect/cpa/o/o8barzkbzmcxdmf3n4as8uo2sv1uypnl/?to=' + encodeURIComponent(location.href);
}
}
break;
}
}
}
}
});
var MenuCommand = GM_registerMenuCommand(dictionary.Settings, function() {
'use strict';
GM_config.open();
});