mirror of
https://github.com/Maks1mS/userscripts.git
synced 2025-10-13 22:42:38 +03:00
Compare commits
11 Commits
6e2eb40def
...
main
Author | SHA1 | Date | |
---|---|---|---|
becff1ef68 | |||
5f002ba7f7 | |||
|
9cad4d315b | ||
|
cf8ed72d1a | ||
38b3fe10be | |||
91e5166b44 | |||
82ea415171 | |||
fbe2e6e830 | |||
5de1a557f1 | |||
|
db9d93407d | ||
32a4239fe4 |
@@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name БЕСПЛАТНЫЕ ПВЗ ОЗОН
|
// @name БЕСПЛАТНЫЕ ПВЗ ОЗОН
|
||||||
// @namespace https://github.com/Maks1mS/userscripts
|
// @namespace https://github.com/Maks1mS/userscripts
|
||||||
// @version 0.1
|
// @version 0.2.1
|
||||||
// @description Заменяет партнерские ПВЗ на понятные адреса
|
// @description Заменяет партнерские ПВЗ на понятные адреса
|
||||||
// @author Maxim Slipenko
|
// @author Maxim Slipenko
|
||||||
// @match https://www.ozon.ru/*
|
// @match https://www.ozon.ru/*
|
||||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=ozon.ru
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=ozon.ru
|
||||||
@@ -99,18 +99,17 @@
|
|||||||
updateInfo(element);
|
updateInfo(element);
|
||||||
addObserver(element, () => {
|
addObserver(element, () => {
|
||||||
updateInfo(element);
|
updateInfo(element);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInfoALL() {
|
function updateInfoALL() {
|
||||||
console.log('updateall!');
|
|
||||||
|
|
||||||
const headerAddress = qs('[data-widget="addressBookBarWeb"] .tsBody400Small');
|
const headerAddress = qs('[data-widget="addressBookBarWeb"] .tsBody400Small');
|
||||||
const commonAddressBook = qsa('[data-widget="commonAddressBook"] .tsBody500Medium');
|
const commonAddressBook = qsa('[data-widget="commonAddressBook"] .tsBody500Medium');
|
||||||
const delivery = qsa('[data-widget="orderDeliveryDetails"] .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);
|
elements.forEach(handleElement);
|
||||||
}
|
}
|
||||||
@@ -120,41 +119,52 @@
|
|||||||
updateInfoALL();
|
updateInfoALL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function onSelectorAdd(targetNode, selector, callback) {
|
||||||
|
function check(s) {
|
||||||
|
const r = qs(s);
|
||||||
|
if (r) {
|
||||||
|
callback(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkSelector() {
|
||||||
|
if (Array.isArray(selector)) {
|
||||||
|
selector.forEach(check);
|
||||||
|
}
|
||||||
|
check(selector);
|
||||||
|
}
|
||||||
|
checkSelector();
|
||||||
|
function handle(mutationsList) {
|
||||||
|
for (let mutation of mutationsList) {
|
||||||
|
if (mutation.type === 'childList') {
|
||||||
|
checkSelector();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addObserver(targetNode, handle, { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
function fullExecute() {
|
function fullExecute() {
|
||||||
if (called) return;
|
if (called) return;
|
||||||
|
|
||||||
called = true;
|
called = true;
|
||||||
|
updateInfoALL();
|
||||||
updateInfoPeriodically(5000);
|
onSelectorAdd(document.body, [
|
||||||
|
'[data-widget="commonAddressBook"]',
|
||||||
function handleNewElement(mutationsList) {
|
], updateInfoALL);
|
||||||
for (let mutation of mutationsList) {
|
|
||||||
if (mutation.type === 'childList') {
|
|
||||||
mutation.addedNodes.forEach(node => {
|
|
||||||
if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains('vue-portal-target')) {
|
|
||||||
setTimeout(() => {
|
|
||||||
updateInfoALL();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const observer = new MutationObserver(handleNewElement);
|
|
||||||
|
|
||||||
const targetNode = document.body;
|
|
||||||
const config = { childList: true, subtree: true };
|
|
||||||
|
|
||||||
observer.observe(targetNode, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('popstate', fullExecute);
|
window.addEventListener('popstate', fullExecute);
|
||||||
window.addEventListener('load', fullExecute);
|
window.addEventListener('load', fullExecute);
|
||||||
document.addEventListener('DOMContentLoaded', fullExecute);
|
document.addEventListener('DOMContentLoaded', fullExecute);
|
||||||
setTimeout(fullExecute, 2500);
|
|
||||||
|
if (document.readyState == "complete" ||
|
||||||
|
document.readyState == "loaded" ||
|
||||||
|
document.readyState == "interactive"
|
||||||
|
) {
|
||||||
|
fullExecute();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
@@ -1,16 +1,17 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Steam Price Converter
|
// @name Steam Price Converter
|
||||||
// @namespace https://github.com/Maks1mS/userscripts
|
// @namespace https://github.com/Maks1mS/userscripts
|
||||||
// @version 0.2
|
// @version 0.7.1
|
||||||
// @description Converts prices to rubles
|
// @description Converts prices to rubles
|
||||||
// @author Maxim Slipenko
|
// @author Maxim Slipenko
|
||||||
// @match https://store.steampowered.com/*
|
// @match https://store.steampowered.com/*
|
||||||
|
// @match https://steamcommunity.com/*
|
||||||
// @icon https://www.google.com/s2/favicons?sz=64&domain=steampowered.com
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=steampowered.com
|
||||||
// @grant GM_xmlhttpRequest
|
// @grant GM_xmlhttpRequest
|
||||||
// @grant GM_registerMenuCommand
|
// @grant GM_registerMenuCommand
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const SYMBOL_TO_CODE_MAPPING = {
|
const SYMBOL_TO_CODE_MAPPING = {
|
||||||
@@ -23,12 +24,15 @@
|
|||||||
source_symbol: undefined
|
source_symbol: undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const delay = (ms) =>
|
||||||
|
new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
|
||||||
async function getRates() {
|
async function getRates() {
|
||||||
const arr = await new Promise((resolve, reject) => {
|
const arr = await new Promise((resolve, reject) => {
|
||||||
GM_xmlhttpRequest({
|
GM_xmlhttpRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: 'https://www.cbr-xml-daily.ru/daily_utf8.xml',
|
url: 'https://www.cbr-xml-daily.ru/daily_utf8.xml',
|
||||||
onload: function(res) {
|
onload: function (res) {
|
||||||
const valutes = res.responseXML.getElementsByTagName('Valute');
|
const valutes = res.responseXML.getElementsByTagName('Valute');
|
||||||
resolve([...valutes].map((valute) => {
|
resolve([...valutes].map((valute) => {
|
||||||
const charCode = valute.getElementsByTagName('CharCode')[0].textContent;
|
const charCode = valute.getElementsByTagName('CharCode')[0].textContent;
|
||||||
@@ -54,6 +58,29 @@
|
|||||||
return SYMBOL_TO_CODE_MAPPING[state.source_symbol];
|
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() {
|
async function main() {
|
||||||
const rates = await getRates();
|
const rates = await getRates();
|
||||||
const source_valute = getCurrentValute();
|
const source_valute = getCurrentValute();
|
||||||
@@ -62,22 +89,76 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const convert = (n) => +(n * rates[source_valute].value).toFixed(2);
|
// await delay(75);
|
||||||
replace(convert);
|
|
||||||
|
|
||||||
GM_registerMenuCommand("update", () => replace(convert), "u");
|
const convert = (n) => +(n * rates[source_valute].value).toFixed(2);
|
||||||
|
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) {
|
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++) {
|
for (let i = 0; i < r.snapshotLength; i++) {
|
||||||
let n = r.snapshotItem(i);
|
let n = r.snapshotItem(i);
|
||||||
const value = parseFloat(n.textContent.replace(" ", "").replace(',', '.'))
|
let textContent = n.textContent;
|
||||||
n.replaceWith(`${convert(value)} ₽`);
|
let regex = new RegExp(`(\\${state.source_symbol}\\s*[0-9\\s]+[.,]?[0-9]*(?:USD)?|[0-9\\s]*[.,]?[0-9]+\\s*\\${state.source_symbol})`, 'g');
|
||||||
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();
|
main();
|
||||||
})();
|
})();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name VK Big Chat Stickers
|
// @name VK Big Chat Stickers
|
||||||
// @namespace https://github.com/Maks1mS/userscripts
|
// @namespace https://github.com/Maks1mS/userscripts
|
||||||
// @version 0.2
|
// @version 0.3
|
||||||
// @description Increases size of chat stickers
|
// @description Increases size of chat stickers
|
||||||
// @author Maxim Slipenko
|
// @author Maxim Slipenko
|
||||||
// @match https://vk.com/*
|
// @match https://vk.com/*
|
||||||
@@ -9,24 +9,28 @@
|
|||||||
// @grant GM_addStyle
|
// @grant GM_addStyle
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function() {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const style = `
|
const style = `
|
||||||
img.StickerUGC {
|
.sticker_img_wrapper:has(.StickerUGC) {
|
||||||
width: 256px;
|
width: 256px;
|
||||||
height: 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 {
|
.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-columns: 2 !important;
|
||||||
--stickers-size: 172px !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 {
|
.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-size: 172px !important;
|
||||||
--sticker-scale: 2 !important;
|
--sticker-scale: 2 !important;
|
||||||
width: 172px !important;
|
width: 172px !important;
|
||||||
height: 172px !important;
|
height: 172px !important;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user