0
0
mirror of https://github.com/Maks1mS/userscripts.git synced 2025-10-13 22:42:38 +03:00

Compare commits

..

8 Commits

Author SHA1 Message Date
becff1ef68 Merge branch 'main' of https://github.com/Maks1mS/userscripts 2024-06-25 21:26:29 +03:00
5f002ba7f7 [FreeOzonDPR] update to 0.2.1
replace delivery in checkout
2024-06-25 21:26:26 +03:00
KaMZeSs
9cad4d315b [VKBigChatStickers] fix increasing stickers
---------

Co-authored-by: Maxim Slipenko <no-reply@maxim.slipenko.com>
2024-06-25 12:32:42 +03:00
KaMZeSs
cf8ed72d1a [VKBigChatStickers] update to 0.3
- update to the sticker icon position (#3)
2024-06-25 10:57:40 +03:00
38b3fe10be [SteamPriceConverter] update to 0.7.1
add steamcommunity (closes #2)
2024-06-24 08:48:02 +03:00
91e5166b44 [SteamPriceConverter] update to 0.7
fix USD
2024-06-23 14:46:43 +03:00
82ea415171 [SteamPriceConverter] update to 0.6
replace prices when body updates
2024-06-23 10:19:20 +03:00
fbe2e6e830 [SteamPriceConverter] update to 0.5
replace only price in textContent
2024-06-22 23:55:35 +03:00
3 changed files with 101 additions and 21 deletions

View File

@@ -1,8 +1,8 @@
// ==UserScript==
// @name БЕСПЛАТНЫЕ ПВЗ ОЗОН
// @namespace https://github.com/Maks1mS/userscripts
// @version 0.2
// @description Заменяет партнерские ПВЗ на понятные адреса
// @version 0.2.1
// @description Заменяет партнерские ПВЗ на понятные адреса
// @author Maxim Slipenko
// @match https://www.ozon.ru/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=ozon.ru
@@ -107,8 +107,9 @@
const headerAddress = qs('[data-widget="addressBookBarWeb"] .tsBody400Small');
const commonAddressBook = qsa('[data-widget="commonAddressBook"] .tsBody500Medium');
const delivery = qsa('[data-widget="orderDeliveryDetails"] .tsBody500Medium');
const delivery2 = qsa('[data-widget="rfbsAddressInfo"] .tsBody500Medium');
const elements = [headerAddress, ...commonAddressBook, ...delivery];
const elements = [headerAddress, ...commonAddressBook, ...delivery, ...delivery2];
elements.forEach(handleElement);
}
@@ -150,7 +151,7 @@
called = true;
updateInfoALL();
onSelectorAdd(document.body, [
'[data-widget="commonAddressBook"]',
'[data-widget="commonAddressBook"]',
], updateInfoALL);
}

View File

@@ -1,10 +1,11 @@
// ==UserScript==
// @name Steam Price Converter
// @namespace https://github.com/Maks1mS/userscripts
// @version 0.4
// @version 0.7.1
// @description Converts prices to rubles
// @author Maxim Slipenko
// @match https://store.steampowered.com/*
// @match https://steamcommunity.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=steampowered.com
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
@@ -23,7 +24,7 @@
source_symbol: undefined
}
const delay = (ms) =>
const delay = (ms) =>
new Promise(resolve => setTimeout(resolve, ms));
async function getRates() {
@@ -57,6 +58,29 @@
return SYMBOL_TO_CODE_MAPPING[state.source_symbol];
}
const observers = new WeakMap();
function addObserver(element, callback, config = { childList: true }) {
if (element && !observers.has(element)) {
const observer = new MutationObserver(callback);
observer.observe(element, config);
observers.set(element, observer);
}
}
function qs(...args) {
return document.querySelector(...args);
}
function debounce(callback, delay) {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => {
callback(...args);
}, delay);
};
}
async function main() {
const rates = await getRates();
const source_valute = getCurrentValute();
@@ -65,25 +89,76 @@
return;
}
await delay(75);
// await delay(75);
const convert = (n) => +(n * rates[source_valute].value).toFixed(2);
replace(convert);
const execute = () => {
replace(convert);
}
const config = { childList: true, subtree: true };
function handle(mutationsList, observer) {
observer.disconnect();
execute();
observer.observe(document.body, config);
}
const debouncedCallback = debounce(handle, 300);
addObserver(document.body, debouncedCallback, config);
window.addEventListener('popstate', execute);
window.addEventListener('load', execute);
document.addEventListener('DOMContentLoaded', execute);
if (document.readyState == "complete" ||
document.readyState == "loaded" ||
document.readyState == "interactive"
) {
execute();
}
// GM_registerMenuCommand("update", () => replace(convert), "u");
}
function replace(convert) {
let r = document.evaluate(`//text()[contains(., \"${state.source_symbol}\")]`, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
let xpath = `//text()[contains(., \"${state.source_symbol}\") and not(ancestor::*[@data-converted]) and not(ancestor::script)]`;
let r = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
for (let i = 0; i < r.snapshotLength; i++) {
let n = r.snapshotItem(i);
const value = parseFloat(n.textContent.replace(" ", "").replace(',', '.'))
let textContent = n.textContent;
let regex = new RegExp(`(\\${state.source_symbol}\\s*[0-9\\s]+[.,]?[0-9]*(?:USD)?|[0-9\\s]*[.,]?[0-9]+\\s*\\${state.source_symbol})`, 'g');
n.replaceWith(`${convert(value)} ₽ / ${value} ${state.source_symbol}`);
console.log(n)
let newContent = textContent.replace(regex, (match) => {
let value;
let originalValue;
originalValue = match.replace(state.source_symbol, '').replace(' ', '').replace(',', '.').trim();
value = parseFloat(originalValue);
let convertedValue = convert(value);
let formattedConvertedValue;
let formattedOriginalValue;
if (match.trim().startsWith(state.source_symbol)) {
formattedOriginalValue = `${state.source_symbol}${originalValue}`;
} else {
formattedOriginalValue = `${originalValue}${state.source_symbol}`;
}
formattedConvertedValue = `${convertedValue}`;
return `${formattedConvertedValue} / ${formattedOriginalValue}`;
});
let newNode = document.createTextNode(newContent);
n.parentNode.setAttribute('data-converted', 'true');
n.parentNode.replaceChild(newNode, n);
// console.log(newNode);
}
}
main();
})();

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name VK Big Chat Stickers
// @namespace https://github.com/Maks1mS/userscripts
// @version 0.2
// @version 0.3
// @description Increases size of chat stickers
// @author Maxim Slipenko
// @match https://vk.com/*
@@ -9,24 +9,28 @@
// @grant GM_addStyle
// ==/UserScript==
(function() {
(function () {
'use strict';
const style = `
img.StickerUGC {
.sticker_img_wrapper:has(.StickerUGC) {
width: 256px;
height: 256px;
}
img.StickerUGC {
height: 100%;
width: 100%;
}
.StickersEmojiKeyboard-module__in--GCR5_:has(.StickersKeyboardGroupItem-module__in--CKjkC.StickersKeyboardGroupItem-module__inActive--iqstp > div[aria-label="Стикеры чата"]) .StickersKeyboard-module__keyboard--HhSGu.View-module__panel--WNKKi.View-module__panelSwitched--hg3jP {
--stickers-columns: 2 !important;
--stickers-size: 172px !important;
--stickers-columns: 2 !important;
--stickers-size: 172px !important;
}
.StickersEmojiKeyboard-module__in--GCR5_:has(.StickersKeyboardGroupItem-module__in--CKjkC.StickersKeyboardGroupItem-module__inActive--iqstp > div[aria-label="Стикеры чата"]) .Sticker-module__sticker--CtZU6.Sticker-module__tappable--M4lob.StickersKeyboardRow-module__sticker--m7W0R {
--sticker-size: 172px !important;
--sticker-scale: 2 !important;
width: 172px !important;
height: 172px !important;
--sticker-size: 172px !important;
--sticker-scale: 2 !important;
width: 172px !important;
height: 172px !important;
}
`;