Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
joshparkerj committed May 26, 2023
2 parents e2478fc + 74d9dbc commit 56485ad
Show file tree
Hide file tree
Showing 27 changed files with 1,322 additions and 146 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
schedule:
- cron: '40 22 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
20 changes: 10 additions & 10 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
Expand All @@ -26,7 +26,7 @@ jobs:
- run: npm install
- run: npm test
- name: Codecov
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
analyze:
needs: build
runs-on: ubuntu-latest
Expand All @@ -40,22 +40,22 @@ jobs:
language: [ 'javascript' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
publish:
needs: analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ wikipedia/result.csv
wikipedia/result.json
wikipedia/uncials.html
youtube/something.js
nightcafe/*.txt
nightcafe/*.json
nightcafe/prompts/
ts-hello-world/
.DS_Store
50-rando-ticker-symbols.json
where-am-i.py
65 changes: 33 additions & 32 deletions bundle-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,40 @@ const octokit = new Octokit({
auth,
});

glob(pattern).then((files) => {
const upload = function upload(i = 0) {
if (i < files.length) {
const file = files[i];
readFile(file, (err, contentBuffer) => {
if (err) {
console.error(err);
} else {
const content = contentBuffer.toString();
const gistId = content.match(/downloadURL.*joshparkerj\/([^/]*)/)[1];
const description = content.match(/description\s+(.*)/)[1];
const filename = file.includes('meta')
? content.match(/updateURL.*raw\/([^/]*)/)[1]
: content.match(/downloadURL.*raw\/([^/]*)/)[1];
glob(pattern)
.then((files) => {
const upload = function upload(i = 0) {
if (i < files.length) {
const file = files[i];
readFile(file, (err, contentBuffer) => {
if (err) {
console.error(err);
} else {
const content = contentBuffer.toString();
const gistIdMatch = content.match(/downloadURL.*joshparkerj\/([^/]*)/);
if (gistIdMatch) {
const gistId = gistIdMatch[1];
const description = content.match(/description\s+(.*)/)[1];
const filename = file.includes('meta') ? content.match(/updateURL.*raw\/([^/]*)/)[1] : content.match(/downloadURL.*raw\/([^/]*)/)[1];

octokit
.request(`PATCH /gists/${gistId}`, {
gist_id: gistId,
description,
files: {
[filename]: {
filename,
content,
},
},
})
.then(() => {
upload(i + 1);
});
}
});
}
};
octokit.request(`PATCH /gists/${gistId}`, {
gist_id: gistId,
description,
files: {
[filename]: {
filename,
content,
},
},
})
.then(() => {
upload(i + 1);
});
}
}
});
}
};

upload();
});
22 changes: 22 additions & 0 deletions egs/arrow-nav.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ==UserScript==
// @name Arrow Key Navigation
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Arrow Key Navigation
// @author Josh Parker
// @match https://www.egscomics.com/comic/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=egscomics.com
// @grant none
// ==/UserScript==

(function arrowKeyNavigation() {
const next = () => document.querySelector('a.cc-next').click();
const previous = () => document.querySelector('a.cc-prev').click();
document.addEventListener('keydown', ({ code }) => {
if (code === 'ArrowRight') {
next();
} else if (code === 'ArrowLeft') {
previous();
}
});
}());
177 changes: 177 additions & 0 deletions itch/duotrigordle-solve.user.js

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions netflix/delete-element.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// ==UserScript==
// @name Delete Element
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Delete Element (with undo)
// @author Josh Parker
// @match http*://**/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=qwant.com
// @grant none
// ==/UserScript==

(function deleteElement() {
const remove = (element) => { element.style.setProperty('display', 'none'); };

// let prevBoxShadow;

const addBorder = (element) => {
// prevBoxShadow = element.style.getPropertyValue('box-shadow');
element.style.setProperty('box-shadow', '0px 0px 1px 1px red');
};

const removeBorder = (element) => {
element.style.removeProperty('box-shadow');
/*
if (prevBoxShadow) {
element.style.setProperty('box-shadow', prevBoxShadow);
} */
};

const elementStack = [];
let hoveredElement;

// eslint-disable-next-line no-extend-native
Array.prototype.peek = function peek() { return this[this.length - 1]; };

// not pressing d
const mouseoverHandler = ({ target }) => {
hoveredElement = target;
};

// pressing d
const mouseoverHandlerWithBorder = ({ target }) => {
removeBorder(hoveredElement);
hoveredElement = target;
addBorder(hoveredElement);
};

const clickHandler = (event) => {
event.preventDefault();
const { target } = event;
elementStack.push(target);
remove(target);
};

const undo = () => {
const element = elementStack.pop();
element?.style.removeProperty('display');
};

const { body } = document;
body.addEventListener('mouseover', mouseoverHandler);

document.addEventListener('keydown', ({ code }) => {
if (code === 'KeyD') {
body.removeEventListener('mouseover', mouseoverHandler);
body.addEventListener('mouseover', mouseoverHandlerWithBorder);
document.addEventListener('click', clickHandler);
addBorder(hoveredElement);
}

if (code === 'KeyZ') {
undo();
}
});

document.addEventListener('keyup', ({ code }) => {
if (code === 'KeyD') {
document.removeEventListener('click', clickHandler);
body.addEventListener('mouseover', mouseoverHandler);
body.removeEventListener('mouseover', mouseoverHandlerWithBorder);
removeBorder(hoveredElement);
}
});
}());
25 changes: 25 additions & 0 deletions netflix/log-element.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ==UserScript==
// @name Console Log Element
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Console Log Element
// @author Josh Parker
// @match http*://**/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=netflix.com
// @grant none
// ==/UserScript==

(function consoleLogElement() {
const logElement = ({ target }) => console.log(target);
document.addEventListener('keydown', ({ code }) => {
if (code === 'KeyL') {
document.addEventListener('click', logElement);
}
});

document.addEventListener('keyup', ({ code }) => {
if (code === 'KeyL') {
document.removeEventListener('click', logElement);
}
});
}());
46 changes: 46 additions & 0 deletions nightcafe/artist-name-collections.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ==UserScript==
// @name Get Collections
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Show the collections that the artist name belongs to
// @author Josh Parker
// @match https://aiartcreation.fandom.com/wiki/Artist_Directory_(Volcano_Comparison)
// @icon https://www.google.com/s2/favicons?sz=64&domain=fandom.com
// @grant none
// ==/UserScript==

(function getCollections() {
const css = `
.wikia-gallery-item > .lightbox-caption > p {
margin: 0;
}
.wikia-gallery-item > .lightbox-caption > p:nth-child(1) {
border-top: solid black 1px;
}
`;

const style = document.createElement('style');
style.appendChild(new Text(css));
document.body.appendChild(style);

const hrefs = [...document.querySelectorAll('li > a[href^="/wiki/Collection"]')].map((e) => e.href);

const parser = new DOMParser();

hrefs.forEach(async (href) => {
const response = await fetch(href);
const htmlText = await response.text();
const dom = parser.parseFromString(htmlText, 'text/html');
const artistNames = [...dom.querySelectorAll('div.lightbox-caption')].map((e) => e.textContent);
const title = dom.querySelector('h1#firstHeading').textContent.trim().match(/Collection: (.*)/)[1];
console.log(title);
console.log(artistNames);
artistNames.forEach((artistName) => {
const artistLightboxCaption = [...document.querySelectorAll('div.lightbox-caption')].find((div) => div.textContent.includes(artistName));
const paragraph = document.createElement('p');
paragraph.appendChild(new Text(title));
artistLightboxCaption.appendChild(paragraph);
});
});
}());
Loading

0 comments on commit 56485ad

Please sign in to comment.