diff --git a/goodreads/series-csv.user.js b/goodreads/series-csv.user.js index e69de29..f26bc84 100644 --- a/goodreads/series-csv.user.js +++ b/goodreads/series-csv.user.js @@ -0,0 +1,53 @@ +// ==UserScript== +// @name series csv +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description goodreads data in tabular and csv format +// @author Josh Parker +// @match https://www.goodreads.com/series/* +// @icon https://www.google.com/s2/favicons?domain=goodreads.com +// @grant none +// ==/UserScript== + +(function userScript() { + let csv = 'title,author,rating,ratings,reviews,date,editions'; + const table = document.createElement('table'); + const thead = document.createElement('thead'); + const tbody = document.createElement('tbody'); + const headerRow = document.createElement('tr'); + csv.split(',').forEach((heading) => { + const th = document.createElement('th'); + th.textContent = heading; + headerRow.appendChild(th); + }); + + thead.appendChild(headerRow); + table.appendChild(thead); + table.appendChild(tbody); + document.querySelectorAll('.responsiveBook').map((rb) => { + const title = rb.querySelector('.gr-h3 span[itemprop="name"]').textContent; + const author = rb.querySelector('span[itemprop="author"]').textContent; + const rating = rb.querySelector('.communityRating__starsWrapper ~ .gr-metaText').textContent; + const allTextContent = rb.textContent; + const matches = allTextContent.match(/(?[\d,]+) Ratings[^\d\w]*((?[\d,]+) Reviews)?[^\d\w]*(published (?\d+))?[^\d\w]*((?\d+) editions)?/); + return { + title, + author, + rating, + ...matches.groups, + }; + }).map(({ + title, author, rating, ratings, reviews, date, editions, + }) => `\n"${title}","${author}","${rating}","${ratings}","${reviews || 0}","${date || 'unknown'}","${editions || 1}"`) + .forEach((row) => { + csv += row; + const bodyRow = document.createElement('tr'); + row.split(',').forEach((d) => { + const td = document.createElement('td'); + td.textContent = d.replaceAll('"', ''); + bodyRow.appendChild(td); + }); + + tbody.appendChild(bodyRow); + }); +}()); diff --git a/rainbowify/zalgoify.user.js b/rainbowify/zalgoify.user.js index 80e3f1f..3fd1b67 100644 --- a/rainbowify/zalgoify.user.js +++ b/rainbowify/zalgoify.user.js @@ -12,9 +12,7 @@ // @grant none // ==/UserScript== -(function () { - 'use strict'; - +(function zalgoifyUserScript() { const body = document.querySelector('body'); const existingTextManips = document.querySelector('body > div.josh-text-manips'); const joshTextManips = existingTextManips || document.createElement('div'); @@ -23,26 +21,26 @@ zalgoifyButton.innerText = 'zalgoify'; // zalgo chars from https://codepen.io/aranromperson/pen/OgOJzX - const zalgoChars = ["̍", "̎", "̄", "̅", "̿", "̑", "̆", "̐", "͒", "͗", "͑", "̇", "̈", "̊", "͂", "̓", "̈́", "͊", "͋", "͌", "̃", "̂", "̌", "̀", "́", "̋", "̏", "̒", "̓", "̔", "̽", "̉", "̾", "͆", "̚", "̖", "̗", "̘", "̙", "̜", "̝", "̞", "̟", "̠", "̤", "̥", "̦", "̩", "̪", "̫", "̬", "̭", "̮", "̯", "̰", "̱", "̲", "̳", "̹", "̺", "̻", "̼", "ͅ", "͇", "͈", "͉", "͍", "͎", "͓", "͚", "̣", "̕", "̛", "̀", "́", "͘", "̡", "̢", "̧", "̨", "̴", "̵", "̶", "͏", "͜", "͝", "͞", "͟", "͠", "͢", "̸", "̷", "͡", "҉"]; + const zalgoChars = ['̍', '̎', '̄', '̅', '̿', '̑', '̆', '̐', '͒', '͗', '͑', '̇', '̈', '̊', '͂', '̓', '̈́', '͊', '͋', '͌', '̃', '̂', '̌', '̀', '́', '̋', '̏', '̒', '̓', '̔', '̽', '̉', '̾', '͆', '̚', '̖', '̗', '̘', '̙', '̜', '̝', '̞', '̟', '̠', '̤', '̥', '̦', '̩', '̪', '̫', '̬', '̭', '̮', '̯', '̰', '̱', '̲', '̳', '̹', '̺', '̻', '̼', 'ͅ', '͇', '͈', '͉', '͍', '͎', '͓', '͚', '̣', '̕', '̛', '̀', '́', '͘', '̡', '̢', '̧', '̨', '̴', '̵', '̶', '͏', '͜', '͝', '͞', '͟', '͠', '͢', '̸', '̷', '͡', '҉']; const changeTextToZalgoText = function changeTextToZalgoText(element) { + const e = element; const randZalg = () => zalgoChars[Math.floor(Math.random() * zalgoChars.length)]; const randZalgs = () => [0, 1, 2, 3, 4].map(() => randZalg()); - const elementLength = element.textContent.length; - element.textContent = element.textContent.split('').map((c, i) => c + randZalgs().join('')).join(''); + e.textContent = e.textContent.split('').map((c) => c + randZalgs().join('')).join(''); }; const zalgoify = function zalgoify({ target }) { body.removeEventListener('mousedown', zalgoify); - const singleLetterSpans = target.textContent.split('').map(c => { + const singleLetterSpans = target.textContent.split('').map((c) => { const singleLetterSpan = document.createElement('span'); singleLetterSpan.textContent = c; return singleLetterSpan; }); target.textContent = ''; - singleLetterSpans.forEach(span => target.appendChild(span)); + singleLetterSpans.forEach((span) => target.appendChild(span)); const zalgoifyMouseover = ({ target: mouseoverTarget }) => { if (mouseoverTarget.tagName === 'SPAN') { @@ -56,7 +54,7 @@ target.removeEventListener('mouseup', zalgoifyMouseup); target.removeEventListener('mouseover', zalgoifyMouseover); const text = target.textContent; - const classNames = [...target.childNodes].map(node => node.className); + const classNames = [...target.childNodes].map((node) => node.className); const selectionStart = classNames.indexOf('selected'); const selectionEnd = classNames.lastIndexOf('selected') + 1; target.innerHTML = `${text.slice(0, selectionStart)}${text.slice(selectionStart, selectionEnd)}${text.slice(selectionEnd)}`; @@ -78,4 +76,4 @@ } document.styleSheets[0].insertRule('.josh-text-manips {position: fixed;background-color: lightgrey;padding: 5px 10px;top: 62px;right: 10px;border-radius: 16px;box-shadow: 2px 2px 1px black;}'); -})(); +}()); diff --git a/text-effect/text-effect.user.js b/text-effect/text-effect.user.js index 886dfbc..194b837 100644 --- a/text-effect/text-effect.user.js +++ b/text-effect/text-effect.user.js @@ -10,7 +10,7 @@ // @grant none // ==/UserScript== -(function userScript() { +(function textEffectUserScript() { const effectify = function effectify(buttonText, effectClassName, applyTextEffect) { const textEffectButton = document.createElement('button'); textEffectButton.innerText = buttonText; @@ -146,6 +146,9 @@ joshTextManips.appendChild(zanyifyButton); // const fidgetifyButton = effectify('fidgetify', 'fidget-text', ) + const blinkifyButton = effectify('blinkify', 'blink-text', (element) => { + + }) addCSSRule('body > div#josh-text-manips { position: fixed; background-color: lightgrey; padding: 5px 10px; top: 62px; right: 10px; border-radius: 16px; box-shadow: 2px 2px 1px black; z-index: 2; display: grid; grid-template-columns: 1fr 1fr 1fr; }'); addCSSRule('body > div#josh-text-manips > button { grid-column: span 1; }'); diff --git a/washington-post-better-colors/wapo-better-colors.user.js b/washington-post-better-colors/wapo-better-colors.user.js index bdca3e8..6661bdb 100644 --- a/washington-post-better-colors/wapo-better-colors.user.js +++ b/washington-post-better-colors/wapo-better-colors.user.js @@ -9,25 +9,24 @@ // @grant none // ==/UserScript== -(function () { - 'use strict'; - +(function wapoBetterColorsUserScript() { const bodyElement = [...document.getElementsByTagName('body')][0]; bodyElement.style.setProperty('text-shadow', 'rgb(127 204 102) 1px 1px 1px, rgb(204 102 127) -1px -1px 1px'); bodyElement.style.setProperty('background-image', 'linear-gradient(45deg, #33ccff, #cc33ff)'); const changeTextToRainbowText = function changeTextToRainbowText(element) { - const elementLength = element.textContent.length; - const singleLetterSpans = element.textContent.split('').map((c, i) => { + const e = element; + const elementLength = e.textContent.length; + const singleLetterSpans = e.textContent.split('').map((c, i) => { const singleLetterSpan = document.createElement('span'); singleLetterSpan.textContent = c; - singleLetterSpan.style.setProperty('color', `hsl(${360 * i / elementLength} 100% 50%)`); + singleLetterSpan.style.setProperty('color', `hsl(${(360 * i) / elementLength} 100% 50%)`); return singleLetterSpan; }); - element.textContent = ''; - singleLetterSpans.forEach(span => element.appendChild(span)); + e.textContent = ''; + singleLetterSpans.forEach((span) => e.appendChild(span)); }; const mainHeading = document.querySelector('.main-content h1'); @@ -36,4 +35,4 @@ changeTextToRainbowText(mainHeading); changeTextToRainbowText(document.querySelector('h1#main-content')); -})(); +}()); diff --git a/wavify/wave-style.css b/wavify/wave-style.css index a6e3fe7..b655882 100644 --- a/wavify/wave-style.css +++ b/wavify/wave-style.css @@ -50,11 +50,11 @@ div { @keyframes wave { from { - transform: translateY(0); + transform: rotate(0); } 25% { - transform: translateY(-100%); + transform: rotate(360deg); } 50% { diff --git a/wiki-category-page-views/fiddle.js b/wiki-category-page-views/fiddle.js index 41a6731..9546ee1 100644 --- a/wiki-category-page-views/fiddle.js +++ b/wiki-category-page-views/fiddle.js @@ -18,11 +18,15 @@ const getPageViewsThisMonth = function getPageViewsThisMonth() { const lastMonthDate = `${thisYear}${lastMonth.toString().padStart(2, '0')}01`; - const pageViewUrls = [...categoryLinks].map(a => `${apiUrl}${a.href.match(/[^\/]*$/)[0]}/monthly/${lastMonthDate}/${today}`); - - Promise.all(pageViewUrls.map(url => fetch(url).then(r.json()).then(json => json.items[0].views))) - .then(results => results.forEach((views, i) => categoryLinks[i].innerText += ` (${views} page views this month)`)); -} + const pageViewUrls = [...categoryLinks].map((a) => `${apiUrl}${a.href.match(/[^/]*$/)[0]}/monthly/${lastMonthDate}/${today}`); + + Promise.all(pageViewUrls.map((url) => ( + fetch(url) + .then((r) => r.json()) + .then((json) => json.items[0].views) + ))) + .then((results) => results.forEach((views, i) => { categoryLinks[i].innerText += ` (${views} page views this month)`; })); +}; getPageViewsThisMonthButton.addEventListener('click', getPageViewsThisMonth); diff --git a/zany/zanyify.user.js b/zany/zanyify.user.js index e69de29..389a601 100644 --- a/zany/zanyify.user.js +++ b/zany/zanyify.user.js @@ -0,0 +1,84 @@ +// ==UserScript== +// @name Zanyify +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description twist the text for a zany effect +// @author Josh Parker +// @match https://www.washingtonpost.com/* +// @match https://www.google.com/* +// @match https://en.wikipedia.org/wiki/* +// @match https://www.tampermonkey.net/* +// @icon https://www.google.com/s2/favicons?domain=washingtonpost.com +// @grant none +// ==/UserScript== + +(function zanyifyUserScript() { + const body = document.querySelector('body'); + const existingTextManips = document.querySelector('body > div.josh-text-manips'); + const joshTextManips = existingTextManips || document.createElement('div'); + joshTextManips.className = 'josh-text-manips'; + const zanyifyButton = document.createElement('button'); + zanyifyButton.innerText = 'zanyify'; + + const changeTextToZanyText = function changeTextToZanyText(element) { + const e = element; + const singleLetterSpans = e.textContent.split('').map((c) => { + const singleLetterSpan = document.createElement('span'); + singleLetterSpan.textContent = c; + singleLetterSpan.style.setProperty('transform', `rotate(${Math.random() / 2 - 0.25}turn)`); + return singleLetterSpan; + }); + + e.textContent = ''; + singleLetterSpans.forEach((span) => e.appendChild(span)); + }; + + const zanyify = function zanyify({ target }) { + const e = target; + body.removeEventListener('mousedown', zanyify); + + const singleLetterSpans = e.textContent.split('').map((c) => { + const singleLetterSpan = document.createElement('span'); + singleLetterSpan.textContent = c; + return singleLetterSpan; + }); + + e.textContent = ''; + singleLetterSpans.forEach((span) => e.appendChild(span)); + + const zanyifyMouseover = ({ target: mouseoverTarget }) => { + const f = mouseoverTarget; + if (f.tagName === 'SPAN') { + f.className = 'selected'; + } + }; + + e.addEventListener('mouseover', zanyifyMouseover); + + const zanyifyMouseup = () => { + e.removeEventListener('mouseup', zanyifyMouseup); + e.removeEventListener('mouseover', zanyifyMouseover); + const text = e.textContent; + const classNames = [...e.childNodes].map((node) => node.className); + const selectionStart = classNames.indexOf('selected'); + const selectionEnd = classNames.lastIndexOf('selected') + 1; + e.innerHTML = `${text.slice(0, selectionStart)}${text.slice(selectionStart, selectionEnd)}${text.slice(selectionEnd)}`; + changeTextToZanyText(e.querySelector('span.zany-text')); + zanyifyButton.removeAttribute('disabled'); + }; + + e.addEventListener('mouseup', zanyifyMouseup); + }; + + zanyifyButton.addEventListener('click', () => { + zanyifyButton.setAttribute('disabled', true); + body.addEventListener('mousedown', zanyify); + }); + + joshTextManips.appendChild(zanyifyButton); + if (!existingTextManips) { + body.appendChild(joshTextManips); + } + + document.styleSheets[0].insertRule('.josh-text-manips {position: fixed;background-color: lightgrey;padding: 5px 10px;top: 62px;right: 10px;border-radius: 16px;box-shadow: 2px 2px 1px black;}'); +}());