Skip to content

Instantly share code, notes, and snippets.

View qiansen1386's full-sized avatar
😉
love & peace

Paris Qian qiansen1386

😉
love & peace
View GitHub Profile
@qiansen1386
qiansen1386 / Inject Lo-dash FP or Ramda to browser console.md
Last active August 27, 2019 08:27
Inject Lo-dash FP/Ramda to browser console

Intro

new version available here

Inject Lodash FP v4/Ramda 0.22 to browser console.
If u prefer bookmarklet, feel free to use any bookmarklet converter you like.
Otherwise, a simple copy-paste in Chrome Console might work too, if the target page is not secured by Tls.
For sake of security, I don't provide any uglified code.
Bookmarklet Crunchinator - ted.mielczarek.org might be helpful.

@qiansen1386
qiansen1386 / main.js
Last active December 19, 2016 05:00
提取淘宝的所有快递单号到电子表格
{
// Get Item Names
const itemElms = document.querySelectorAll('[class^="index-mod__order-container___"]');
console.log(itemElms);
//let firstElm = fp.first(itemElms);
const findName = itemElm => itemElm.querySelector('span[style="line-height:16px;"]').textContent;
const findNumber = itemElm => itemElm.querySelector('label[class^="bought-wrapper-mod__checkbox-label___"] + span>span:nth-child(3)').textContent;
const concatTarget = itemElm => ({ 'name': findName(itemElm), 'bizOrderId': findNumber(itemElm) });
const fetchExpressStatus = object => {
fetch(`https://buyertrade.taobao.com/trade/json/transit_step.do?bizOrderId=${object.bizOrderId}`, { credentials: 'same-origin' }).then(res => res.json()).then(json => object['express'] = json);
@qiansen1386
qiansen1386 / Inject any lib.js
Last active December 19, 2016 04:44
Advanced version of script injection script
// a. CDN like jsdelivr.com can load multiple script with one url
// b. predicate condition can be omit
var scripts2Load = [{ 'name': name, url: "", 'predicate': () => true }];
// Example:
//var scripts2Load = [{ 'name': 'Lodash',
//url: 'https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)',
//'predicate': () => window._ }];
((window) => {
// Change it if you want.
const timeout = 2000;
def calc(total,people,treat,split_among):
amt = {}
plate = total/(sum(people.values())+treat)
print("{0:.2f} per plate\n".format(plate))
for k,v in people.items():
print("{} consumed {}".format(k,v))
amt[k] = plate * v
else:
print()