Skip to content

Instantly share code, notes, and snippets.

@hexium310
hexium310 / disable-unfollow-button.user.css
Last active October 31, 2024 09:11
A style for disabling unfollow button at the user's bio and the more dropdown in Twitter
/* ==UserStyle==
@name Disable Unfollow Button
@namespace github.com/hexium310
@version 0.0.2
@preprocessor default
==/UserStyle== */
@document url-prefix("https://x.com/") {
[data-testid$="unfollow"], [data-testid="Dropdown"]:has(> a[href$="/quotes"]) > :has(+ a[href="/i/lists/add_member"]) {
pointer-events: none;
@hexium310
hexium310 / bookmarklet.js
Last active October 31, 2024 21:28
A bookmarklet to save an image opening on Twitter
javascript:(async()=>{const url=location.href;const[,tweetId,nth]=url.match(/\/status\/(\d+)\/photo\/(\d)/);const modal=document.querySelector('div[style*="transition-duration:"][style*="background-color:"]');const ul=[...modal.querySelectorAll("ul")].find(elm=>[...elm.style].includes("transform"));const imgQuery='img[src^="https://pbs.twimg.com/media/"]';const img=ul!==undefined?[...ul.querySelectorAll(imgQuery)][nth-1]:[...modal.querySelectorAll(imgQuery)].find(elm=>elm.parentNode.getAttribute("data-testid")!=="tweetPhoto");const imgUrl=img.src;const blob=await fetch(imgUrl).then(res=>res.blob());const blobType=blob?.type;if(!/^image\/.+$/.test(blobType)){return}const objectUrl=URL.createObjectURL(blob);const anchor=document.createElement("a");anchor.href=objectUrl;anchor.download=`twitter_${tweetId}_${nth}`;anchor.click();URL.revokeObjectURL(objectUrl)})();
@hexium310
hexium310 / bookmarklet.js
Last active April 17, 2022 10:38
Copy title and URL to clipboard
javascript:{const t=document.title+" "+location.href,o=t=>{window.prompt("",t)};navigator?.clipboard?.writeText(t).catch(()=>{o(t)})||o(t)}
@hexium310
hexium310 / make-docs.rs-latest.user.js
Last active May 13, 2022 10:29
Make docs.rs latest on Google Search
// ==UserScript==
// @name Make docs.rs latest on Google Search
// @namespace hexium310
// @version 0.0.1
// @author Hexin
// @include /^(http|https):\/\/www\.google\..+\/search.*/
// @downloadUrl https://gist.github.com/hexium310/774465f10e34740849d653c277cf9ab6/raw/make-docs.rs-latest.user.js
// @updateUrl https://gist.github.com/hexium310/774465f10e34740849d653c277cf9ab6/raw/make-docs.rs-latest.user.js
// ==/UserScript==
git revert $(git log --oneline | nl >&2; read -p '> ' num; git log --format='%h' --skip=$((num - 1)) -1)
@hexium310
hexium310 / head.zsh
Created September 30, 2021 06:43
Use `HEAD` in `git pull`, `git rebase` and so on
autoload -Uz add-zsh-hook
__set_head() {
if git rev-parse --show-toplevel > /dev/null 2>&1; then
alias -g HEAD=$(git symbolic-ref --short \HEAD)
fi
}
__set_head
add-zsh-hook chpwd __set_head
@hexium310
hexium310 / switch-plain-md-github.user.js
Last active September 25, 2021 13:38
This userscript adds a button for switching plain/rich for a Markdown blob on GitHub.
// ==UserScript==
// @name Switching Plain for Markdown on GitHub
// @namespace hexium310
// @version 0.3
// @description This userscript adds a button for switching plain/rich for a Markdown blob on GitHub.
// @author Hexin
// @match https://*.github.com/*/*
// @downloadURL https://gist.github.com/hexium310/76eda31e03f7bd09227133a26364bbe8/raw/switch-plain-md-github.user.js
// @updateURL https://gist.github.com/hexium310/76eda31e03f7bd09227133a26364bbe8/raw/switch-plain-md-github.user.js
// @grant none
@hexium310
hexium310 / .textlintrc generator
Last active June 11, 2021 09:41
A .textlintrc generator
cat <<< $(jq '{ rules: [{ key: .devDependencies | keys | map(match("(@textlint-.+/)?textlint-rule-.+").string | gsub("^textlint-rule-"; ""))[], value: true }] | from_entries }' package.json | jq -s '.[1] * .[0]' .textlintrc.json -) > .textlintrc.json
@hexium310
hexium310 / group-by-range.zsh
Last active June 9, 2021 16:48
group-by-range
group-by-range() {
setopt LOCAL_OPTIONS EXTENDED_GLOB
local value
local values=(${(ps: :)1})
local separator=${2--}
local tmp_separator=,
local result=()
local positives=(${(no)${(M)values:#[[:digit:]]##}})
local negatives=(${(nO)${(M)values:#-[[:digit:]]##}})
@hexium310
hexium310 / a.zsh
Last active June 2, 2021 18:20
queryのみが書かれたファイルをgh api graphql --inputでつかうやつ
gh api graphql --input <(jq -n --arg owner hexium310 --arg name brew-uo --arg query "$(cat file | tr '\n' ' ')" '{ query: $query, variables: { owner: $owner, name: $name } }')