Skip to content

Instantly share code, notes, and snippets.

@bastsoft
Last active April 12, 2018 12:07
Show Gist options
  • Save bastsoft/11ef5b1b1c3e6cc0b4bd666d4ed20d42 to your computer and use it in GitHub Desktop.
Save bastsoft/11ef5b1b1c3e6cc0b4bd666d4ed20d42 to your computer and use it in GitHub Desktop.
Inspect Moscowfresh
var arr = Array.prototype.slice;
arr.call(document.querySelectorAll('.quick-status')).forEach(function (select) {
var optionComplete = document.createElement("OPTION");
optionComplete.setAttribute("value", "complete");
optionComplete.appendChild(document.createTextNode("6. завершен"));
var optionCanceled = document.createElement("OPTION");
optionCanceled.setAttribute("value", "canceled");
optionCanceled.appendChild(document.createTextNode("отменен"));
var pendingCreate = document.createElement("OPTION");
pendingCreate.setAttribute("value", "pending_create");
pendingCreate.appendChild(document.createTextNode("1. принят"));
select.appendChild(optionComplete);
select.appendChild(optionCanceled);
select.appendChild(pendingCreate);
});
var optionComplete = document.createElement("OPTION");
optionComplete.setAttribute("value", "complete");
optionComplete.appendChild(document.createTextNode("6. завершен"));
var optionCanceled = document.createElement("OPTION");
optionCanceled.setAttribute("value", "canceled");
optionCanceled.appendChild(document.createTextNode("отменен"));
var pendingCreate = document.createElement("OPTION");
pendingCreate.setAttribute("value", "pending_create");
pendingCreate.appendChild(document.createTextNode("1. принят"));
document.querySelector('select[name="history[status]"]').appendChild(optionComplete);
document.querySelector('select[name="history[status]"]').appendChild(optionCanceled);
document.querySelector('select[name="history[status]"]').appendChild(pendingCreate);
// var invoiceId=prompt('invoiceId : ');
var invoiceId=Math.round(Math.random() * 1000000000000000);
var items = window.moscowFreshData.yandexKassa.items;
var request = new XMLHttpRequest();
var params = "history_id=" + items[0].id + "&action=paymentAviso&shopSumAmount=" + items[0].sum + "&invoiceId=" + invoiceId;
request.open('POST', window.location.origin + '/yamoney/index/aviso', true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
request.onload = function(){
console.log(request.response);
};
request.send(params);
var getItogo = function (TD) {
return Array.prototype.slice.call(
document.querySelectorAll('.orderItemsTable-original table tr>td:nth-child(' + TD + ')')
).reduce(function (acc, x) {
var num = parseInt(x.innerText.replace(/\s|\,|руб|\./g, ''));
return num ? (acc + num) : acc;
}, 0);
};
console.log('Предварительный итог : ', getItogo(6));
console.log('Величина скидки : ', getItogo(7));
console.log('Итог строки : ', getItogo(8));
alert("Предварительный итог : " + getItogo(6) + "\n" +
'Величина скидки : ' + getItogo(7) + "\n" +
'Итог строки : ' + getItogo(8) + "\n");
btr.loadGist({ url: 'https://gist.github.com/', id: '11ef5b1b1c3e6cc0b4bd666d4ed20d42'}, function(){
btr.contextMenu('body', {
'feedbackLink': btr.functionGist('feedbackLink.js'),
'getOrderTableItogo': btr.functionGist('getOrderTableItogo.js'),
'order_add_status': btr.functionGist('addStusInHistorySelectOrder.js'),
'addStusInGrid': btr.functionGist('addStusInGrid.js'),
'поставить холд (желтый) yamoney/index/aviso stub': btr.functionGist('avisoStub.js'),
'show inline-storage' : btr.functionGist('showInlineStorage.js'),
'cart' : {
'gotoStepThankYou' : function(){
moscowFresh.actions.CartActions.popupOpen();
moscowFresh.actions.CartActions.goToStep('thank-you');
},
'gotoStepEpaySuccess' : function(){
moscowFresh.actions.CartActions.popupOpen();
moscowFresh.actions.CartActions.goToStep('epay-success');
},
'gotoStepEpayFail' : function(){
moscowFresh.actions.CartActions.popupOpen();
moscowFresh.actions.CartActions.goToStep('epay-fail');
},
'gotoStepEpay' : function(){
moscowFresh.actions.CartActions.showEpayPopup({
ePayId:"10",
ePayRedirectUrl:'https://money.yandex.ru/eshop.xml?shopId=73662&scid=68810&paymentType=AC&shopSuccessURL="http://moscowfresh.puphpet/"&shopFailURL="http://moscowfresh.puphpet/"&shopDefaultUrl="http://moscowfresh.puphpet/"&sum=5320&orderNumber=100019403&customerNumber=40&cps_email=compsober@yandex.ru&history_id=10',
ecash_payment:"1"
});
},
'AutoForm' : function(){
moscowFresh.actions.CartActions.popupOpen();
moscowFresh.actions.CartActions.goToStep('delivery');
moscowFresh.actions.CartActions.changeDeliveryField({
'name':'address',
'value': 'Это тест. И мой адрес слишком известин чтобы я его называл'
});
moscowFresh.actions.CartActions.changeDeliveryField({
'name':'comment',
'value': 'Что сказать в комментарии на тестиовый заказ?'
});
moscowFresh.actions.CartActions.changeDeliveryField({
'name':'name',
'value': 'Петя'
});
moscowFresh.actions.CartActions.changeDeliveryField({
'name':'phone',
'value': '+7 (999) 999-99-99'
});
}
}
});
alert('вызовите контекстное меню на странице');
});
var inlineStorage = JSON.parse(document.querySelector('.inline-storage').innerHTML);
console.log('inlineStorage : ', inlineStorage);
javascript:(function(){
var el = document.createElement('script');
el.onload = el.onreadystatechange = function () {
if (el.readyState && el.readyState !== "complete" && el.readyState !== "loaded") {
return false;
}
btr.loadGist({ id: '11ef5b1b1c3e6cc0b4bd666d4ed20d42', file: 'main.js' });
};
document.getElementsByTagName('head')[0].appendChild(el).src = 'https://cdn.rawgit.com/bastsoft/btr/v0.1.0/btr.js';
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment