Skip to content

Instantly share code, notes, and snippets.

View duplaja's full-sized avatar

Dan D. duplaja

  • Central US
View GitHub Profile
@duplaja
duplaja / fixdiscordspellcheck.js
Last active April 13, 2022 18:35
Fix Discord Web Browser Spellcheck
window.addEventListener("load", fixStupidDiscordSpellcheck, false);
window.addEventListener('locationchange', fixStupidDiscordSpellcheck, false);
window.addEventListener('hashchange', fixStupidDiscordSpellcheck, false);
function fixStupidDiscordSpellcheck(event){
setTimeout(function() {
var textBoxes = document.querySelectorAll('div[role="textbox"]');
@duplaja
duplaja / librarything.js
Last active April 12, 2022 18:57
Rate LibraryThing Works
window.addEventListener("load", function(event) {
const ratingtd = document.getElementById("ratingstdtitle");
const orig_rating = document.getElementById("form_rating").value;
const button = document.createElement('a');
button.setAttribute("id", "rate-button");
button.innerHTML = "<h3>Rate Book (Current Rating: "+orig_rating+")</h3>"
@duplaja
duplaja / weighted-spin.php
Last active March 27, 2022 17:39
Weighted "Spin the Prize Wheel" function
<?php
function lottery_spin_the_wheel() {
//Form is key (reward as string) value (frequency as int)
$rewards_master = array(
'1 bonus token'=>25,
'5-album mini themed list'=>20,
'Album on demand'=>20,
'Trade 1 token for 2 tokens of your choice'=>15,
'Top-off overload +5 on Wednesday'=>10,
@duplaja
duplaja / wp-equipment-post-type.php
Created March 26, 2022 13:18
WordPress Equipment Post Type
<?php
if ( ! function_exists('register_equpiment_post_type') ) {
// Register Custom Post Type
function register_equpiment_post_type() {
$labels = array(
'name' => 'Equipment',
'singular_name' => 'Equpiment',
@duplaja
duplaja / download-text.js
Created March 24, 2022 14:55
Export Table as List - Text File
function generateDownload(filename, text, type='text/plain') {
// Create an invisible A element
const a = document.createElement('a');
a.style.display = 'none';
document.body.appendChild(a);
// Set the HREF to a Blob representation of the data to be downloaded
a.href = window.URL.createObjectURL(
new Blob([text], { type })
);

Links

(http/https): https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)

Number followed by Period and Space

^(\d+)\.\s

@duplaja
duplaja / allmusic-ratings.js
Last active February 3, 2022 00:48
Updated No-Jquery Allmusic Recs Gist
window.addEventListener("load", function(event) {
var userratingdiv = document.getElementsByClassName("ratings")[0];
const button = document.createElement('a');
button.setAttribute("id", "rate-button");
button.innerHTML = '<h3>Rate Album</h3>'
userratingdiv.insertBefore(button, userratingdiv.firstChild)
var userratingbutton = document.getElementById("rate-button");
@duplaja
duplaja / rym-charts-scraper.js
Created September 25, 2021 00:39
JS Scraper for RYM Charts page
getRYMChart();
function getRYMChart() {
const rows = [["Artist-Album","Release","Genres","Link"]]
var tables = document.querySelectorAll("div.chart_results_frame");
var recTable = tables[0];
var tableRows = recTable.querySelectorAll("div.topcharts_itembox");
@duplaja
duplaja / custom-first-shuffle.js
Created September 12, 2021 22:09
Custom JS Shuffle - Keep First
function customShuffle(x) {
var y = x.slice(1, x.length);
var j, t, i;
for (i = y.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
t = y[i];
y[i] = y[j];
y[j] = t;
}
return [x[0]].concat(y);
@duplaja
duplaja / spotispin-csv-downloader.js
Created September 5, 2021 03:04
Spotispin CSV Downloader
getSpotispin();
function getSpotispin() {
const rows = [["Artists-Album","Link"]]
var tableRows = document.querySelectorAll("tr.single_rec");
for (i = 0; i < tableRows.length; i++) {
combined = tableRows[i].querySelectorAll("td.album_name")[0].innerText.trim();