Last active
July 30, 2021 06:08
-
-
Save alimertcakar/6a72fbf579ee0c333220a1f80506b33c to your computer and use it in GitHub Desktop.
satıcı getir fz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://www.farmazon.com.tr/cart | |
// @icon https://www.google.com/s2/favicons?domain=farmazon.com.tr | |
// @grant none | |
// ==/UserScript== | |
/*Arrive js*/ | |
var Arrive=function(e,t,n){"use strict";function r(e,t,n){l.addMethod(t,n,e.unbindEvent),l.addMethod(t,n,e.unbindEventWithSelectorOrCallback),l.addMethod(t,n,e.unbindEventWithSelectorAndCallback)}function i(e){e.arrive=f.bindEvent,r(f,e,"unbindArrive"),e.leave=d.bindEvent,r(d,e,"unbindLeave")}if(e.MutationObserver&&"undefined"!=typeof HTMLElement){var o=0,l=function(){var t=HTMLElement.prototype.matches||HTMLElement.prototype.webkitMatchesSelector||HTMLElement.prototype.mozMatchesSelector||HTMLElement.prototype.msMatchesSelector;return{matchesSelector:function(e,n){return e instanceof HTMLElement&&t.call(e,n)},addMethod:function(e,t,r){var i=e[t];e[t]=function(){return r.length==arguments.length?r.apply(this,arguments):"function"==typeof i?i.apply(this,arguments):n}},callCallbacks:function(e,t){t&&t.options.onceOnly&&1==t.firedElems.length&&(e=[e[0]]);for(var n,r=0;n=e[r];r++)n&&n.callback&&n.callback.call(n.elem,n.elem);t&&t.options.onceOnly&&1==t.firedElems.length&&t.me.unbindEventWithSelectorAndCallback.call(t.target,t.selector,t.callback)},checkChildNodesRecursively:function(e,t,n,r){for(var i,o=0;i=e[o];o++)n(i,t,r)&&r.push({callback:t.callback,elem:i}),i.childNodes.length>0&&l.checkChildNodesRecursively(i.childNodes,t,n,r)},mergeArrays:function(e,t){var n,r={};for(n in e)e.hasOwnProperty(n)&&(r[n]=e[n]);for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);return r},toElementsArray:function(t){return n===t||"number"==typeof t.length&&t!==e||(t=[t]),t}}}(),c=function(){var e=function(){this._eventsBucket=[],this._beforeAdding=null,this._beforeRemoving=null};return e.prototype.addEvent=function(e,t,n,r){var i={target:e,selector:t,options:n,callback:r,firedElems:[]};return this._beforeAdding&&this._beforeAdding(i),this._eventsBucket.push(i),i},e.prototype.removeEvent=function(e){for(var t,n=this._eventsBucket.length-1;t=this._eventsBucket[n];n--)if(e(t)){this._beforeRemoving&&this._beforeRemoving(t);var r=this._eventsBucket.splice(n,1);r&&r.length&&(r[0].callback=null)}},e.prototype.beforeAdding=function(e){this._beforeAdding=e},e.prototype.beforeRemoving=function(e){this._beforeRemoving=e},e}(),a=function(t,r){var i=new c,o=this,a={fireOnAttributesModification:!1};return i.beforeAdding(function(n){var i,l=n.target;(l===e.document||l===e)&&(l=document.getElementsByTagName("html")[0]),i=new MutationObserver(function(e){r.call(this,e,n)});var c=t(n.options);i.observe(l,c),n.observer=i,n.me=o}),i.beforeRemoving(function(e){e.observer.disconnect()}),this.bindEvent=function(e,t,n){t=l.mergeArrays(a,t);for(var r=l.toElementsArray(this),o=0;o<r.length;o++)i.addEvent(r[o],e,t,n)},this.unbindEvent=function(){var e=l.toElementsArray(this);i.removeEvent(function(t){for(var r=0;r<e.length;r++)if(this===n||t.target===e[r])return!0;return!1})},this.unbindEventWithSelectorOrCallback=function(e){var t,r=l.toElementsArray(this),o=e;t="function"==typeof e?function(e){for(var t=0;t<r.length;t++)if((this===n||e.target===r[t])&&e.callback===o)return!0;return!1}:function(t){for(var i=0;i<r.length;i++)if((this===n||t.target===r[i])&&t.selector===e)return!0;return!1},i.removeEvent(t)},this.unbindEventWithSelectorAndCallback=function(e,t){var r=l.toElementsArray(this);i.removeEvent(function(i){for(var o=0;o<r.length;o++)if((this===n||i.target===r[o])&&i.selector===e&&i.callback===t)return!0;return!1})},this},s=function(){function e(e){var t={attributes:!1,childList:!0,subtree:!0};return e.fireOnAttributesModification&&(t.attributes=!0),t}function t(e,t){e.forEach(function(e){var n=e.addedNodes,i=e.target,o=[];null!==n&&n.length>0?l.checkChildNodesRecursively(n,t,r,o):"attributes"===e.type&&r(i,t,o)&&o.push({callback:t.callback,elem:i}),l.callCallbacks(o,t)})}function r(e,t){return l.matchesSelector(e,t.selector)&&(e._id===n&&(e._id=o++),-1==t.firedElems.indexOf(e._id))?(t.firedElems.push(e._id),!0):!1}var i={fireOnAttributesModification:!1,onceOnly:!1,existing:!1};f=new a(e,t);var c=f.bindEvent;return f.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t);var o=l.toElementsArray(this);if(t.existing){for(var a=[],s=0;s<o.length;s++)for(var u=o[s].querySelectorAll(e),f=0;f<u.length;f++)a.push({callback:r,elem:u[f]});if(t.onceOnly&&a.length)return r.call(a[0].elem,a[0].elem);setTimeout(l.callCallbacks,1,a)}c.call(this,e,t,r)},f},u=function(){function e(){var e={childList:!0,subtree:!0};return e}function t(e,t){e.forEach(function(e){var n=e.removedNodes,i=[];null!==n&&n.length>0&&l.checkChildNodesRecursively(n,t,r,i),l.callCallbacks(i,t)})}function r(e,t){return l.matchesSelector(e,t.selector)}var i={};d=new a(e,t);var o=d.bindEvent;return d.bindEvent=function(e,t,r){n===r?(r=t,t=i):t=l.mergeArrays(i,t),o.call(this,e,t,r)},d},f=new s,d=new u;t&&i(t.fn),i(HTMLElement.prototype),i(NodeList.prototype),i(HTMLCollection.prototype),i(HTMLDocument.prototype),i(Window.prototype);var h={};return r(f,h,"unbindAllArrive"),r(d,h,"unbindAllLeave"),h}}(window,"undefined"==typeof jQuery?null:jQuery,void 0); | |
(function() { | |
'use strict'; | |
function $$(selector, context) { | |
context = context || document; | |
var elements = context.querySelectorAll(selector); | |
return Array.prototype.slice.call(elements); | |
} | |
function FindReact(dom, traverseUp = 0) { | |
const key = Object.keys(dom).find(key=>{ | |
return key.startsWith("__reactFiber$") // react 17+ | |
|| key.startsWith("__reactInternalInstance$"); // react <17 | |
}); | |
const domFiber = dom[key]; | |
if (domFiber == null) return null; | |
// react 16+ | |
const GetCompFiber = fiber=>{ | |
//return fiber._debugOwner; // this also works, but is __DEV__ only | |
let parentFiber = fiber.return; | |
while (typeof parentFiber.type == "string") { | |
parentFiber = parentFiber.return; | |
} | |
return parentFiber; | |
}; | |
let compFiber = GetCompFiber(domFiber); | |
for (let i = 0; i < traverseUp; i++) { | |
compFiber = GetCompFiber(compFiber); | |
} | |
return compFiber; | |
} | |
function desiBul(saticiAdi){ | |
const bulunanSaticilar = []; | |
window.store.data.forEach(satici=>{ | |
const lowercaseUsername = satici.username.toLowerCase(); | |
if(lowercaseUsername.includes(saticiAdi.toLowerCase())){ | |
bulunanSaticilar.push({urun:"gereksiz, silindi", satici:satici}); | |
} | |
}) | |
if(bulunanSaticilar.length>1){ | |
return "Birden fazla satıcı bulundu! Birkaç harf daha ekle."; | |
} | |
else if(bulunanSaticilar.length<1){ | |
return "Hiç sonuç bulunamadı! Hatalı arama yaptın!"; | |
} | |
else{ | |
const satici = bulunanSaticilar[0].satici; | |
const currentDesiText = satici.boxInfo.size; | |
const currentDesiPercentage = satici.boxInfo.percentage; | |
const urunShipmentCompany = satici.cargoPricingBox.shipmentCompany; | |
const currentDesiAraligi = satici.cargoPricingBox.details.filter(aralik=>aralik.size === currentDesiText); | |
let gercekDesi; | |
{ | |
const {maxRange,minRange} = currentDesiAraligi[0]; | |
const yuzdedenGelenDesi = (maxRange - minRange) * (currentDesiPercentage / 100); | |
gercekDesi = yuzdedenGelenDesi + minRange; | |
} | |
//Onemliler: currentDesiAraligi, urunShipmentCompany | |
return [bulunanSaticilar, {gercekDesi}]; | |
} | |
} | |
window.desiBul = desiBul; | |
function Popup(tiklananSatici) { | |
const cart = document.querySelector(".cart"); | |
window.store = FindReact(cart).return.memoizedProps.value[0]; | |
var DesiModal = document.createElement("dialog"); | |
//kapat | |
var CloseButton = document.createElement("div"); | |
var closeText = document.createTextNode("KAPAT"); | |
CloseButton.appendChild(closeText); | |
DesiModal.appendChild(CloseButton); | |
CloseButton.addEventListener('click', function() { | |
DesiModal.remove(); | |
}); | |
DesiModal.style.position = "absolute;" | |
document.body.appendChild(DesiModal); | |
var text = document.createTextNode("Aranacak Satıcı:"); | |
DesiModal.appendChild(text); | |
var AramaSonucu = document.createElement("div"); | |
var aramaText = document.createTextNode("Arama Sonucu:"); | |
//Arama Inputu | |
var AraInput = document.createElement("input"); | |
function sonucGoster(sonuc){ | |
if(Array.isArray(sonuc)){ | |
const firmalar =sonuc[0][0].satici.shipmentCompanyPricings; | |
const kargoFirmasi = firmalar.filter(firma=>firma.shipmentCompanyId === sonuc[0][0].satici.shipmentCompany); | |
console.log(kargoFirmasi,"kargoFirmasi") | |
AramaSonucu.innerHTML = `<hr> | |
<div>Satıcı: ${sonuc[0][0].satici.username} </div> | |
<div>Kargo Firması: ${kargoFirmasi[0].shipmentCompanyName} </div> | |
<hr> | |
<div>SATICI TOPLAM DESİ: ${sonuc[1].gercekDesi}</div> | |
`; | |
}else{ | |
AramaSonucu.innerHTML = sonuc; | |
} | |
} | |
//satıcıya ctrl tık yaparak aradıysa | |
if(tiklananSatici){ | |
const sonuc = desiBul(tiklananSatici); | |
AraInput.value = tiklananSatici; | |
sonucGoster(sonuc); | |
} | |
//manuel aradıysa | |
AraInput.onkeydown = function (event) { | |
if(event.key === 'Enter') { | |
const sonuc = desiBul(AraInput.value); | |
sonucGoster(sonuc); | |
} | |
}; | |
DesiModal.appendChild(AraInput); | |
AramaSonucu.appendChild(aramaText); | |
DesiModal.appendChild(AramaSonucu); | |
DesiModal.showModal(); | |
} | |
//! kısayol tuşuyla açsın | |
//Disable default help popup | |
window.onhelp = function() { | |
return false; | |
}; | |
window.onkeydown = evt => { | |
switch (evt.keyCode) { | |
//ESC | |
case 27: | |
break; | |
//F1 | |
case 112: | |
break; | |
//Fallback to default browser behaviour | |
default: | |
return true; | |
} | |
//Returning false overrides default browser event | |
return false; | |
}; | |
document.arrive(".cart-content-seller", function(elem) { | |
elem.addEventListener("click", (event) => { | |
if (event.ctrlKey) { | |
const tiklananSatici = elem.querySelector(".f-button.link").innerText; | |
Popup(tiklananSatici); | |
} | |
}) | |
}); | |
//! satıcıya tıklayınca açsın | |
$$(".cart-content-seller").forEach(sellerCard => { | |
sellerCard.addEventListener("click", (event) => { | |
if (event.ctrlKey) { | |
const tiklananSatici = sellerCard.querySelector(".f-button.link").innerText; | |
Popup(tiklananSatici); | |
} | |
}) | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment