Skip to content

Instantly share code, notes, and snippets.

View zhanhongtao's full-sized avatar
😀
Out sick

redky zhanhongtao

😀
Out sick
View GitHub Profile
@zhanhongtao
zhanhongtao / task.user.js
Last active March 26, 2024 03:16
auto-run-script-for-task
// ==UserScript==
// @name auto-run-script-for-every-task
// @namespace https://x181.cn/
// @version 0.30.0
// @author TT
// @description Hello world!
// @icon https://img.artproglobal.com/c/21736720685ad57d4fb8362b70f62f8d?width=512&height=512&hTag=d7a495871ba01409369e6c2231ad49f0
// @homepage https://x181.cn
// @downloadURL https://gist.github.com/zhanhongtao/198e58075d4b3415c2f0f5e394204c6a/raw/task.user.js
// @updateURL https://gist.github.com/zhanhongtao/198e58075d4b3415c2f0f5e394204c6a/raw/task.user.js
/*
参考:
https://saisumit.wordpress.com/2016/01/26/suffix-automaton/
https://ksmeow.moe/suffix_automaton/
https://www.cnblogs.com/meowww/p/6394960.html
https://codeforces.com/blog/entry/20861
https://yeah.moe/p/a8e74947/
*/
// prefix
function TreeNode(val) {
this.val = val
this.left = this.right = null
}
module.exports = function list2tree(list) {
let tree = null
let length = list.length
let padding = 0
let nodes = []
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>cross</title>
</head>
<body>
<script>
@zhanhongtao
zhanhongtao / fixed.rewrite.user.js
Last active October 24, 2017 09:50
fixed.rewrite
// ==UserScript==
// @name x181-fixed-zhihu-rewrite
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author tt
// @match https://*.zhihu.com/*
// @match https://www.google.com/*
// @match https://www.google.com.hk/*
// @match https://www.so.com/*
@zhanhongtao
zhanhongtao / walk.js
Created May 8, 2015 01:00
遍历 DOM 树
function walk(root, handle) {
if (!root) return;
if (root.nodeType !=1 && root.nodeType != 11) return;
for (var node = root.firstChild; node; node = node.nextSibling) {
walk(node, handle);
handle(node);
}
}
@zhanhongtao
zhanhongtao / imageLoader.js
Created April 28, 2015 12:24
图片下载器, 支持 callback
;(function(root, factory) {
if(typeof define === 'function' && define.amd) {
define([], factory);
} else if(typeof exports === 'object') {
module.exports = factory();
} else {
root.imageLoader = factory();
}
})(this, function() {
'use strict';
@zhanhongtao
zhanhongtao / co-an.js
Created March 8, 2015 01:08
Promise + Yield
// Promise
// 1. p1
function p1(value) {
return new Promise(function(resolve, reject) {
setTimeout(function() {
resolve(value);
}, 200);
});
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
</body>
</html>
@zhanhongtao
zhanhongtao / arguments.js
Created June 29, 2014 04:23
形参和 arguments
// arguments 类数组和形参
function $( selector, context ) {
// default
console.log( arguments ); // 'div'
console.log( selector, context ); // 'div', undefined
// 更新 selector
selector = 'p';
console.log( arguments ); // 'p'
console.log( selector ); // 'p'