From 4089b6579c0d6b97edd12c3bdbd43e598f356513 Mon Sep 17 00:00:00 2001 From: szialajoscosplay <70654182+k3rielit@users.noreply.github.com> Date: Sun, 29 May 2022 21:39:48 +0200 Subject: [PATCH] refreshed readme, added more scripts --- README.md | 27 ++-- dotnetfiddle/README.md | 10 ++ dotnetfiddle/dotnetfiddle_dl.user.js | 74 +++++++++ oktatas_hu/README.md | 4 +- steamcharts/README.md | 20 +++ steamcharts/extendedsteamcharts.user.js | 197 ++++++++++++++++++++++++ vectors/README.md | 5 + vectors/vectorpreviews.user.js | 117 ++++++++++++++ 8 files changed, 440 insertions(+), 14 deletions(-) create mode 100644 dotnetfiddle/README.md create mode 100644 dotnetfiddle/dotnetfiddle_dl.user.js create mode 100644 steamcharts/README.md create mode 100644 steamcharts/extendedsteamcharts.user.js create mode 100644 vectors/README.md create mode 100644 vectors/vectorpreviews.user.js diff --git a/README.md b/README.md index eb7eea1..135ebbb 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,16 @@ # Scripts -funny userscript collection to confuse chrome -## Quick installs: -* antileet - * [soft](https://github.com/k3rielit/scripts/raw/main/antileet/hard.user.js) - * [hard](https://github.com/k3rielit/scripts/raw/main/antileet/soft.user.js) - * [sziauram](https://github.com/k3rielit/scripts/raw/main/antileet/sziauram.user.js) -* Flippity - * [normal](https://github.com/k3rielit/scripts/raw/main/flippity/flippity-tamperm.user.js) - * [funny](https://github.com/k3rielit/scripts/raw/main/flippity/ultimity-tamperm.user.js) -* NR Addons [livemap](https://github.com/k3rielit/scripts/raw/main/nr_addons/nr_livemap.user.js) -* Oktatas.hu [normal](https://github.com/k3rielit/scripts/raw/main/oktatas_hu/oktatas_hu.user.js) -* Wizer.me [normal](https://github.com/k3rielit/scripts/raw/main/wizerme/wizerme.user.js) +Some funny userscripts to confuse chrome. + +Details about each script can be found inside their directory. + +| Directory | Install | +|--------------------------------|---------| +| [antileet](/antileet/) | [[soft](https://github.com/k3rielit/scripts/raw/main/antileet/hard.user.js)] [[hard](https://github.com/k3rielit/scripts/raw/main/antileet/soft.user.js)] [[sziauram](https://github.com/k3rielit/scripts/raw/main/antileet/sziauram.user.js)] | +| [dotnetfiddle](/dotnetfiddle/) | [[downloader](https://github.com/k3rielit/scripts/raw/main/dotnetfiddle/dotnetfiddle_dl.user.js)] | +| [flippity](/flippity/) | [[solver](https://github.com/k3rielit/scripts/raw/main/flippity/flippity-tamperm.user.js)] [[advanced](https://github.com/k3rielit/scripts/raw/main/flippity/ultimity-tamperm.user.js)] | +| [nr_addons](/nr_addons/) | [[livemap](https://github.com/k3rielit/scripts/raw/main/nr_addons/nr_livemap.user.js)] | +| [oktatas_hu](/oktatas_hu/) | [[splitscreen](https://github.com/k3rielit/scripts/raw/main/oktatas_hu/oktatas_hu.user.js)] | +| [steamcharts](/steamcharts/) | [[extended](https://github.com/k3rielit/scripts/raw/main/steamcharts/extendedsteamcharts.user.js)] | +| [vectors](/vectors/) | [[previews](https://github.com/k3rielit/scripts/raw/main/vectors/vectorpreviews.user.js)] | +| [wizerme](/wizerme/) | [[solver](https://github.com/k3rielit/scripts/raw/main/wizerme/wizerme.user.js)] | +| [youtube](/youtube/) | [[normalize-links](https://github.com/k3rielit/scripts/raw/main/youtube/normalize-links.user.js)] | \ No newline at end of file diff --git a/dotnetfiddle/README.md b/dotnetfiddle/README.md new file mode 100644 index 0000000..27e9dbf --- /dev/null +++ b/dotnetfiddle/README.md @@ -0,0 +1,10 @@ +# DotNetFiddle +Adds a download button into the navbar for [dotnetfiddle](https://dotnetfiddle.net/) projects, next to `Save` on the left. Should work with every type of project, 1 file for each code window. + +**Filename(s)**: `_.cs` +- Type: `Console` / `Controller` / `View` / `Model` / etc +- Name: The content of the textbox above the code, or `Program` if that's empty. + +### Install: +1. Install the Tampermonkey extension. ([Link](https://www.tampermonkey.net)) +2. [Install](https://github.com/k3rielit/scripts/raw/main/dotnetfiddle/dotnetfiddle_dl.user.js) the script. diff --git a/dotnetfiddle/dotnetfiddle_dl.user.js b/dotnetfiddle/dotnetfiddle_dl.user.js new file mode 100644 index 0000000..241caea --- /dev/null +++ b/dotnetfiddle/dotnetfiddle_dl.user.js @@ -0,0 +1,74 @@ +// ==UserScript== +// @name DotNetFiddle Downloader +// @namespace http://tampermonkey.net/ +// @version 0.2 +// @description Adds a Download button to the top to save the code faster. +// @author k3rielit +// @match https://dotnetfiddle.net/ +// @icon https://www.google.com/s2/favicons?domain=dotnetfiddle.net +// @grant none +// @downloadURL https://github.com/k3rielit/scripts/raw/main/dotnetfiddle/dotnetfiddle_dl.user.js +// ==/UserScript== + +(function() { + 'use strict'; + // file download function: https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server + let saveFile = function(filename, content) { + const blob = new Blob([content], {type: 'text'}); + if(window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveBlob(blob, filename); + } + else{ + const elem = window.document.createElement('a'); + elem.style.display = "none"; + elem.href = window.URL.createObjectURL(blob, { oneTimeOnly: true }); + elem.download = filename; + document.body.appendChild(elem); + elem.click(); + document.body.removeChild(elem); + } + } + // create the download button + let dl = document.createElement('button'); + dl.className = 'btn btn-default'; + dl.innerHTML = ``; + dl.onclick = function() { + // get the file's name from the text input on the page + let filename = (document.querySelector("#CodeForm > div.main.docked > div.status-line > div.name-container > input[type=text]").value || 'Program')+'.cs'; + // try getCodeBlocks(): https://stackoverflow.com/questions/7306669/how-to-get-all-properties-values-of-a-javascript-object-without-knowing-the-key + if(fiddle && fiddle.getCodeBlocks) { + let cobj = fiddle.getCodeBlocks(); + for (let ckey in cobj) { + if (Object.prototype.hasOwnProperty.call(cobj, ckey)) { + saveFile(ckey+'_'+filename,cobj[ckey]); + } + } + } + // or getEditors(): https://stackoverflow.com/questions/7306669/how-to-get-all-properties-values-of-a-javascript-object-without-knowing-the-key + else if(fiddle && fiddle.getEditors) { + let eobj = fiddle.getEditors(); + for (let ekey in eobj) { + if (Object.prototype.hasOwnProperty.call(eobj, ekey)) { + saveFile(ekey+'_'+filename,eobj[ekey].options.value); + } + } + } + // or just get it from the page (there's a chance that the editor will remove the invisible part of the code even when scrolling) + else { + let index = 0; + [...document.querySelectorAll('.CodeMirror-scroll')].map(m => { + let originalScroll = m.scrollTop+0; + m.scrollTop = Number.MAX_SAFE_INTEGER; + // wait for the scroll to take effect, then revert (to force loading all of the code lines) + setTimeout(() => { + m.scrollTop = originalScroll; + let content = [...[...document.querySelectorAll('div.CodeMirror-code')][index].cloneNode(true).querySelectorAll('.CodeMirror-line')].map(l => l.innerText).join('\n'); + saveFile((index+1)+"_"+filename,content); + index++; + }); + }); + } + }; + // append the download button + document.querySelector('#top-navbar > div.navbar-center-container > div.navbar-center-container > div:nth-child(1)').appendChild(dl); +})(); \ No newline at end of file diff --git a/oktatas_hu/README.md b/oktatas_hu/README.md index de41ba1..f264ca3 100644 --- a/oktatas_hu/README.md +++ b/oktatas_hu/README.md @@ -1,6 +1,6 @@ -## Oktatás.hu +## Oktatas.hu Az oktatas.hu-s pdf oldalakra 2 gombot rak, Az egyik megnyitja új lapon a feladat megoldókulcs párját, a másik fél képernyőre rakja. **Telepítés**: 1. Tampermonkey bővítmény telepítése. ([Link](https://www.tampermonkey.net)) -2. [telepítés](https://github.com/k3rielit/scripts/raw/main/oktatas_hu/oktatas_hu.user.js) \ No newline at end of file +2. Script [Telepítés](https://github.com/k3rielit/scripts/raw/main/oktatas_hu/oktatas_hu.user.js) \ No newline at end of file diff --git a/steamcharts/README.md b/steamcharts/README.md new file mode 100644 index 0000000..21bf552 --- /dev/null +++ b/steamcharts/README.md @@ -0,0 +1,20 @@ +# Steam Charts +Some extra features for [steamcharts](https://steamcharts.com) ([example](https://steamcharts.com/app/218620)). + +### Features: +- **JSON data** `top right` + - Open in New Tab + - Download Original + - Download Processed + - Log to Console +- **Steam** `top right` + - Play + - Install + - Store Page + - Community Hub +- **Details** `middle` + - Table with the full data (similar to the chart) + +### Install: +1. Install the Tampermonkey extension. ([Link](https://www.tampermonkey.net)) +2. [Install](https://github.com/k3rielit/scripts/raw/main/steamcharts/extendedsteamcharts.user.js) the script. diff --git a/steamcharts/extendedsteamcharts.user.js b/steamcharts/extendedsteamcharts.user.js new file mode 100644 index 0000000..6a40a28 --- /dev/null +++ b/steamcharts/extendedsteamcharts.user.js @@ -0,0 +1,197 @@ +// ==UserScript== +// @name ExtendedSteamCharts +// @namespace http://tampermonkey.net/ +// @version 0.2 +// @description Add more features to steamcharts. +// @author k3rielit +// @match *://*.steamcharts.com/app/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=steamcharts.com +// @grant none +// @downloadURL https://github.com/k3rielit/scripts/raw/main/steamcharts/extendedsteamcharts.user.js +// ==/UserScript== + +(function() { + 'use strict'; + const toInt = function(text) { + let result = parseInt(text ?? '0'); + return isNaN(result) ? 0 : result; + }; + const toFloat = function(text) { + let result = parseFloat(text ?? '0'); + return isNaN(result) ? 0 : result; + }; + const saveFile = function(filename, content) { + const blob = new Blob([content], {type: 'text'}); + if(window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveBlob(blob, filename); + } + else{ + const elem = window.document.createElement('a'); + elem.style.display = "none"; + elem.href = window.URL.createObjectURL(blob, { oneTimeOnly: true }); + elem.download = filename; + document.body.appendChild(elem); + elem.click(); + document.body.removeChild(elem); + } + } + const decideGain = function(current,previous) { + if(current==previous) {return '';} + else {return current>previous ? 'gain' : 'loss';} + } + const filepath = location.origin+location.pathname+'/chart-data.json'; + const steamid = toInt(location.pathname.split('/')[2]); + const gametitle = document.querySelector('#app-title > a').innerText; + const currentIsoTime = new Date().toISOString(); + // CSS + let style = document.createElement('style'); + style.innerText = ` + .collapsible { + background-color: #1a1a1a; + color: white; + cursor: pointer; + padding: 14px; + width: 100%; + border: none; + text-align: left; + outline: none; + font-size: 15px; + } + + .active, .collapsible:hover { + background-color: #222222; + } + + .collapsible:after { + content: '+'; + color: white; + font-weight: bold; + float: right; + margin-left: 5px; + } + + .active:after { + content: "-"; + } + + .collapsible-content { + max-height: 0; + overflow: hidden; + transition: max-height 0.2s ease-out; + background-color: #1a1a1a; + margin-bottom: 20px; + padding: 0 14px; + } + + + .dropdown { + position: relative; + display: inline-block; + } + + .dropdown-content { + display: none; + position: absolute; + right: 0; + background-color: #1a1a1a; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; + white-space: nowrap; + width: fit-content; + text-align: left; + } + + .dropdown-content a { + padding: 6px 10px 6px 10px; + text-decoration: none; + display: block; + } + + .dropdown-content a:hover {background-color: #222222;} + .dropdown:hover .dropdown-content {display: block;} + `; + document.head.appendChild(style); + // HTML + document.querySelector('#app-links').innerHTML = ` + + | + + `; + // JS + document.querySelector('#json-nt').href = filepath; + fetch(filepath).then(raw => raw.json()).then(data => { + let processedData = { + name: gametitle, + steamid: steamid, + time: currentIsoTime, + summary: [...document.querySelectorAll('.common-table > tbody > tr')].map(row => { + let content = row.innerText.split('\t'); + return { + period: content[0], + averagePlayers: toFloat(content[1].replaceAll(',','')), + gain: toFloat(content[2].replaceAll(',','')), + gainPercent: toFloat(content[3].replaceAll(',','').replaceAll('%','')), + peakPlayers: toFloat(content[4].replaceAll(',','')), + }; + }), + data: structuredClone(data).map((m,i) => { + return { + ticks: m[0], + time: new Date(m[0]).toISOString(), + players: m[1], + } + }), + }; + document.querySelector('#json-do').addEventListener('click',() => { + saveFile(`steamcharts-${(steamid > 0 ? steamid : 'data')}-${currentIsoTime}.original.json`,JSON.stringify(data,null,4)); + },false); + document.querySelector('#json-dp').addEventListener('click',() => { + saveFile(`steamcharts-${(steamid > 0 ? steamid : 'data')}-${currentIsoTime}.processed.json`,JSON.stringify(processedData,null,4)); + },false); + document.querySelector('#json-lc').addEventListener('click',() => { + console.log({original:data, processed:processedData}); + },false); + // details table + let collapsible = document.createElement('div'); + collapsible.id = 'app-details'; + collapsible.innerHTML = ` + +
+ + + + + + + + + ${data.reverse().map((md,i) => + ` + + + + `).join('\n')} + +
TimePlayers
#${i+1}${new Date(md[0]).toISOString()}${md[1]}
+
+ `; + document.querySelector('#content-wrapper').insertBefore(collapsible,document.querySelector('#app-hours-content')); + }); + document.querySelector('#app-title > a').innerHTML = `${gametitle}`; +})(); \ No newline at end of file diff --git a/vectors/README.md b/vectors/README.md new file mode 100644 index 0000000..411170a --- /dev/null +++ b/vectors/README.md @@ -0,0 +1,5 @@ +# Vectors +Some extra features for the [vector-templates](https://www.vector-templates.com) ([example](https://www.vector-templates.com/templates/show/hongqi_e-hs9/21749/)) and [the-blueprints](https://www.the-blueprints.com) ([example](https://www.the-blueprints.com/vectordrawings/show/21749/hongqi_e-hs9/)) preview pages. +### Install: +1. Install the Tampermonkey extension. ([Link](https://www.tampermonkey.net)) +2. [Install](https://github.com/k3rielit/scripts/raw/main/vectors/vectorpreviews.user.js) the script. diff --git a/vectors/vectorpreviews.user.js b/vectors/vectorpreviews.user.js new file mode 100644 index 0000000..55a658f --- /dev/null +++ b/vectors/vectorpreviews.user.js @@ -0,0 +1,117 @@ +// ==UserScript== +// @name VectorPreviews +// @namespace http://tampermonkey.net/ +// @version 0.3 +// @description Loads other images on the preview pages and provide mirror links. +// @author k3rielit +// @match *://*.vector-templates.com/* +// @match *://*.the-blueprints.com/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=vector-templates.com +// @grant none +// @downloadURL https://github.com/k3rielit/scripts/raw/main/vectors/vectorpreviews.user.js +// ==/UserScript== + +(function() { + 'use strict'; + // Constants + const _nums = '0123456789'; + const _year = new Date().getFullYear(); + const _previewTemplate = ` +
+ +

%title% [Download]

+
+ + + +
`; + // Utils + const VUtils = { + extractNum(str,autoStop = true) { + let result = ''; + for(let c of str) { + if(result.length>0 && autoStop && !_nums.includes(c)) return result; + result += _nums.includes(c) ? c : ''; + } + return result; + }, + getVectorData({id,name,years}) { + let data = { + id, + name, + years, + previews: [ + {path:`https://www.vector-templates.com/modules/templates/preview-wm/${id}-wm.jpg`, htmltext:`Sharp ~1055x716`}, + {path:`https://www.the-blueprints.com/modules/vectordrawings/preview-wm/${name}.jpg`, htmltext:`Blurry ~1280x866`}, + {path:`https://www.the-blueprints.com/modules/vectordrawings/preview-wm/${name}_${years[0]}.jpg`, htmltext:`Blurry ~1280x866`}, + {path:`https://www.the-blueprints.com/modules/vectordrawings/preview-wm/${name}_${years[1]}.jpg`, htmltext:`Blurry ~1280x866`}, + {path:`https://www.vector-templates.com/modules/templates/preview/${id}-mid-wm.jpg`, htmltext:`~500x338`}, + {path:`https://www.the-blueprints.com/modules/vectordrawings/preview/${id}-mid.jpg`, htmltext:`~400x271`}, + {path:`https://www.vector-templates.com/modules/templates/preview/${id}-thmb.jpg`, htmltext:`~255x159`}, + ], + previews_backup: [], + pages: [ + `https://www.the-blueprints.com/vectordrawings/show/${id}/${name}/`, + `https://www.the-blueprints.com/vectordrawings/show/${id}`, + `https://www.vector-templates.com/templates/show/${name}/${id}/`, + ], + }; + for(let tempYear = years[0]+1; tempYear < years[1]; tempYear++) { + data.previews_backup.push({path:`https://www.the-blueprints.com/modules/vectordrawings/preview-wm/${name}_${tempYear}.jpg`, htmltext:'Blurry ~1280x866'}); + } + data.previews.map(pre => pre.htmltext = _previewTemplate.replaceAll('%title%',pre.htmltext).replaceAll('%src%',pre.path)); + data.previews_backup.map(pre => pre.htmltext = _previewTemplate.replaceAll('%title%',pre.htmltext).replaceAll('%src%',pre.path)); + return data; + }, + genElem(tag,attrs,classList,id,innerHTML) { // tag:string attrs:object classList:[] id:string innerHTML:string + let elem = document.createElement(tag); // 'div' [['attr','val'],['a','v']] ['col','row'] 'frame' '

kekw

' + attrs.forEach(attr => { + if(attr.length==2 && !elem.hasAttribute(attr[0])) elem.setAttribute(attr[0],attr[1]); + }); + classList.forEach(className => { + if(className.length>0 && !elem.classList.contains(className)) elem.classList.add(className); + }); + if(!elem.id && id && id.length>0) elem.id = id; + elem.innerHTML = innerHTML; + return elem; + }, + } + // Logic + const pages = { + + "vector-templates.com/templates/show/": () => { + const path = location.pathname.split('/').filter(f => f.length>0); + const metadata = { + id: path[3], + name: path.length>2 ? path[2] : document.querySelector('.VectorShowTitle').innerText.toLowerCase().replaceAll(' ','_'), + years: document.querySelector('.VectorShowInfo > table > tbody > tr > td:nth-child(2)').innerText.replaceAll('present',_year).split('-').map(m => m.trim()).concat([_year,_year]).slice(0,2).map(m2 => parseInt(m2)), + }; + const data = VUtils.getVectorData(metadata); + console.log(data); + const previewContainer = document.querySelector('.VectorShowPreview'); + previewContainer.innerHTML = '

Clicking the image opens it on a new tab.

'+data.previews.map(p => p.htmltext).join('\n'); + document.querySelector('.VectorShowInfo > table > tbody').insertBefore(VUtils.genElem('tr',[],[],null,`Mirror(s)the-blueprints.com
the-blueprints.com (2)`), document.querySelectorAll('.VectorShowInfo > table > tbody > tr')[2]); + }, + + "the-blueprints.com/vectordrawings/show/": () => { + const path = location.pathname.split('/').filter(f => f.length>0); + const metadata = { + id: path[2], + name: path.length>3 ? path[3] : document.querySelector('.MainContainer > h1').innerText.toLowerCase().replaceAll(' ','_'), + years: document.querySelector('.VectorInfo > tbody > tr > td:nth-child(2)').innerText.replaceAll('present',_year).split('-').map(m => m.trim()).concat([_year,_year]).slice(0,2).map(m2 => parseInt(m2)), + }; + const data = VUtils.getVectorData(metadata); + console.log(data); + const previewContainer = document.querySelector('#PreviewContainer'); + previewContainer.innerHTML = '

Clicking the image opens it on a new tab.

'+data.previews.map(p => p.htmltext).join('\n'); + document.querySelector('.VectorInfo > tbody').insertBefore(VUtils.genElem('tr',[],[],null,`Mirror(s)vector-templates.com`), document.querySelectorAll('.VectorInfo > tbody > tr')[1]); + }, + + } + Object.keys(pages).forEach(key => { + if(location.href.includes(key)) { + pages[key](); + return; + } + }); +})(); \ No newline at end of file