Skip to content

Instantly share code, notes, and snippets.

View lingsamuel's full-sized avatar
🌌
Busy

Sarasa Kisaragi lingsamuel

🌌
Busy
View GitHub Profile
@lingsamuel
lingsamuel / main.cpp
Created April 20, 2016 15:26 — forked from Axure/main.cpp
C++ Meta Programming like Lisp
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <deque>
#include <type_traits>
using std::cout;
using std::endl;
@lingsamuel
lingsamuel / fuckzhenghu.js
Created December 21, 2016 06:39
aLittleJavascriptProblem
function *range(x, y) {
for (let i = x; i <= y; i++)
yield i;
}
function *map(generator, f) {
for (let x of generator) {
yield f(x);
}
}
@lingsamuel
lingsamuel / steamCostCalculator.js
Created March 4, 2017 12:57
A simple script used in https://store.steampowered.com/account/history/ to calculate your total cost.(Simplified Chinese)
[].reduce.call(document.body.querySelectorAll(".wht_total"), (acc, x) => {let yyy = x.textContent.trim().replace(/[¥\s资金总计]/g,''); console.log(yyy); return acc + parseFloat(yyy||0)}, 0)
@lingsamuel
lingsamuel / expr.js
Created August 8, 2017 06:40
Expression Transpiler
function tokenize(program) {
// this function can help you tokenize program
// you can use this function in attempt
const regex = /\s*(->|[-+*/\(\)\[\]\{\};,]|[A-Za-z]+|[0-9]+)\s*/g;
return program.replace(regex, ":$1").substring(1).split(':');
};
let parser;
let isNumeric = n => !isNaN(parseFloat(n)) && isFinite(n);
let isChar = char => char.length === 1 && char.match(/[a-z]/i);
@lingsamuel
lingsamuel / steam_cart_item_names.js
Last active September 2, 2018 20:11
Output all items' name in Steam cart
// In https://store.steampowered.com/cart/
// Get array
Array.from(document.getElementsByClassName("cart_item_desc")).map(x=>x.innerText);
// Get title text
Array.from(document.getElementsByClassName("cart_item_desc")).map(x=>x.innerText).join("");
@lingsamuel
lingsamuel / getURLs.js
Last active May 20, 2023 05:46
How to download Twitter images in batches(Chrome)
// 0. Press F12, open network panel, select img filter
// 1. Open media page in Twitter(https://twitter.com/user_name/media)
// 2. Hold page down to get a loooots of images, you can see that in network panel
// 3. Right click a filename and select 'Copy=>Copy all as HAR'
// 4. Using JavaScript to extract image URLs.
let har = [ /*paste*/ ];
function getURL(harsObj, mimeArray) {
let results = [];
@lingsamuel
lingsamuel / extract.js
Created August 23, 2018 05:07
Extract raw text from TXDocs
Array.from(document.getElementById("editor").getElementsByTagName("div")).map(x=>x.innerText).join("\n")
@lingsamuel
lingsamuel / calculate_steam_wishlist.js
Last active December 21, 2018 02:48
Calculate Steam wish list
// Usage:
// Copy and paste [base] part into F12-Console at your Steam wishlist page(https://store.steampowered.com/wishlist/id/username)
// Copy and paste [price] part into F12-Console to show your wishlist total price
// Copy and paste [names] part into F12-Console to show your wishlist game names
// ======================= [BASE] ============================
let items = this.top.g_Wishlist.rgElements;
let appIds = Object.keys(items);
@lingsamuel
lingsamuel / export_tabs.js
Created November 22, 2018 16:16
Export Android Chrome tabs
//https://android.stackexchange.com/questions/56635/how-can-i-export-the-list-of-open-chrome-tabs
tabs = Array.from(document.querySelectorAll('div /deep/ div /deep/ div /deep/ div /deep/ div /deep/ .device-page-list .vbox'), s => ({name: s.querySelector('.device-page-title').textContent, url: s.querySelector('.device-page-url .devtools-link').href}))
str = '';
for (i=0;i<tabs.length;i++){
str += '['+tabs[i]['name']+']('+tabs[i]['url']+')\n'
}
@lingsamuel
lingsamuel / synced-tabs.js
Last active September 27, 2021 17:44
Backup Chrome synced tabs!
// use this in PC-Chrome history page (ctrl+H)
var itemList = Array.from(document.
getElementById('history-app').shadowRoot.getElementById('synced-devices').shadowRoot.
getElementById('synced-device-list').getElementsByTagName('history-synced-device-card')).
map(x=>x.shadowRoot.getElementById('tab-item-list')).map(x=>x.getElementsByClassName('website-link'));
// if you want to backup only one device, enter a index number here (start from 0)
// I suggest you use extension OneTab to manage tabs, so I export OneTab's url format
// <url> | <title>