0
0
mirror of https://github.com/Maks1mS/userscripts.git synced 2025-03-31 06:33:50 +03:00

Compare commits

..

No commits in common. "1e5f939be008393deb95667c7bf76c57c5c18d0d" and "b6ff5584696b490900569a837d359a68ad81908d" have entirely different histories.

2 changed files with 31 additions and 34 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Github Link External Resources // @name Github Link External Resources
// @namespace https://github.com/Maks1mS/userscripts // @namespace https://github.com/Maks1mS/userscripts
// @version 0.2 // @version 0.1
// @description Github Link External Resources // @description Github Link External Resources
// @author Maxim Slipenko // @author Maxim Slipenko
// @match https://github.com/* // @match https://github.com/*
@ -30,9 +30,8 @@
} }
function t(key) { function t(key) {
const currentLang = navigator.language || 'en-US'; const currentLang = navigator.language;
const shortLang = currentLang.split('-')[0]; return translations?.[currentLang]?.[key] ?? translations?.['en-US'] ?? key;
return translations?.[currentLang]?.[key] ?? translations?.[shortLang]?.[key] ?? translations?.['en-US']?.[key] ?? key;
} }
const settingsId = 'GithubLinkExternalResources'; const settingsId = 'GithubLinkExternalResources';
@ -47,7 +46,7 @@
data: { data: {
label: t('config'), label: t('config'),
type: 'textarea', type: 'textarea',
// github prefix org or org/repo | prefix | url ($2 - numeric identifier) // github prefix org or org/repo | prefix | url ($1 - numeric identifier)
default: 'pyside | PYSIDE- | https://bugreports.qt.io/browse/$1' default: 'pyside | PYSIDE- | https://bugreports.qt.io/browse/$1'
}, },
}, },
@ -67,7 +66,6 @@
const selector = '.js-issue-title.markdown-title,' + const selector = '.js-issue-title.markdown-title,' +
'.js-navigation-open.markdown-title,' + '.js-navigation-open.markdown-title,' +
'.commit-title.markdown-title,' +
'#partial-actions-workflow-runs .Link--primary,' + // actions '#partial-actions-workflow-runs .Link--primary,' + // actions
'.repository-content h3.PageHeader-title > span > span,' + // actions '.repository-content h3.PageHeader-title > span > span,' + // actions
'div.my-2.Details-content--hidden,' + // commit message 'div.my-2.Details-content--hidden,' + // commit message
@ -75,8 +73,7 @@
const replace = (node, row) => { const replace = (node, row) => {
if (!node) return; if (!node) return;
const re = new RegExp(`\\b(${row[1]}(\\d+))\\b(?!<\\/a>|")`, 'g'); const re = new RegExp(`\\b(${row[1]}\\d+)\\b(?!<\\/a>|")`, 'g');
console.log(re);
node.innerHTML = node.innerHTML.replace(re, `<a href="${row[2]}">$1</a>`); node.innerHTML = node.innerHTML.replace(re, `<a href="${row[2]}">$1</a>`);
} }
@ -84,15 +81,16 @@
const run = (url) => { const run = (url) => {
const row = data.find(row => url.startsWith(`https://github.com/${row[0]}`)); const row = data.find(row => url.startsWith(`https://github.com/${row[0]}`));
console.log(data);
if (!row) return; console.log(row)
console.log(row);
const matches = document.querySelectorAll(selector) const matches = document.querySelectorAll(selector)
matches.forEach(n => replace(n, row)); matches.forEach(n => replace(n, row));
} }
const onInit = gmc => new Promise(resolve => { const onInit = gmc => new Promise(resolve => {
let isInit = () => setTimeout(() => gmc.isInit ? resolve() : isInit(), 0); let isInit = () => setTimeout(() =>
gmc.isInit ? resolve() : isInit(), 0);
isInit(); isInit();
}); });
@ -104,5 +102,4 @@
}); });
} }
}); });
})(); })();

View File

@ -1,7 +1,7 @@
// ==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.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/*
@ -50,8 +50,8 @@
function getCurrentValute() { function getCurrentValute() {
const walletText = document.getElementById('header_wallet_balance').innerText; const walletText = document.getElementById('header_wallet_balance').innerText;
state.source_symbol = Object.keys(SYMBOL_TO_CODE_MAPPING).find(symbol => walletText.includes(symbol)) const symbol = Object.keys(SYMBOL_TO_CODE_MAPPING).find(symbol => walletText.includes(symbol))
return SYMBOL_TO_CODE_MAPPING[state.source_symbol]; return SYMBOL_TO_CODE_MAPPING[symbol];
} }
async function main() { async function main() {
@ -69,7 +69,7 @@
} }
function replace(convert) { function replace(convert) {
let r = document.evaluate(`//text()[contains(., \"${state.source_symbol}\")]`,document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); let r = document.evaluate('//text()[contains(., \"₸\")]',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);