Skip to content

Instantly share code, notes, and snippets.

View maple3142's full-sized avatar

maple maple3142

  • Taiwan
  • 00:26 (UTC +08:00)
  • X @maple3142
View GitHub Profile
@maple3142
maple3142 / cvt.js
Created March 11, 2018 11:41
convert userscript's metablock to javascript object
const m=`
// @name 動畫瘋工具箱
// @namespace https://blog.maple3142.net/
// @version 0.4
// @description 取得動畫的 m3u8 網址,下載彈幕為 json,去除擋廣告的警告訊息
// @author maple3142
// @match https://ani.gamer.com.tw/animeVideo.php?sn=*
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/m3u8-parser.min.js
// @grant none
`
@maple3142
maple3142 / 螺旋矩陣.js
Created March 16, 2018 06:50
【問題】螺旋矩陣(有非C語言的解法嗎 https://forum.gamer.com.tw/C.php?bsn=60076&snA=4453621
const n=3
function c2da(n,m){
const ar=[]
for(let i=0;i<n;i++)ar[i]=[]
return ar
}
const ar=c2da(n+1,n+1)
const vis=c2da(n+1,n+1)
const X=[1,0,-1,0]
const Y=[0,-1,0,1]
(await Promise.all($('a').toArray().filter(x=>/^http.*\d{10}$/.test(x.textContent)).slice(1).map(r=>r.textContent.trim().replace('http:','https:')).map(x=>{
return Promise.all([fetch(x).then(x=>x.text()),fetch(x+'?pn=2').then(x=>x.text())])
}))).map(x=>{
if($(x[0]).find('.l_pager').text())return x.join('')
else return x[0]
}).map(x=>$(x).find('.d_post_content').toArray().reduce((d,x)=>{
const div=document.createElement('div')
div.innerHTML=x.innerHTML.replace(/<br>/g,'\n').replace(/&lt;/g,'<').replace(/&gt;/g,'>')
if(div.textContent.replace(/(\n| )/g,'').length>=50&&!div.textContent.includes('广告')&&!div.textContent.includes('免费'))return d+'\n'+div.textContent
@maple3142
maple3142 / onbeforescriptexecute.js
Last active July 7, 2020 00:58 — forked from jspenguin2017/onbeforescriptexecute.html
polyfill of 'beforescriptexecute' event
// 'beforescriptexecute' event [es5]
// original version: https://gist.github.com/jspenguin2017/cd568a50128c71e515738413cd09a890
;(function() {
;('use strict')
function Event(script, target) {
this.script = script
this.target = target
this._cancel = false
@maple3142
maple3142 / show_git_branch.lua
Last active September 26, 2021 14:14
clink show git branch
function show_git_branch()
for line in io.popen("git branch 2>nul"):lines() do
local m = line:match("%* (.+)$")
local b = "\x1b[32;22;49m".."("..m..")".."\x1b[39;22;49m"
if m then
clink.prompt.value = clink.prompt.value:gsub(">"," "..b.." >")
break
end
end
return false
(await Promise.all([1,2,3].map(x=>fetch(`https://tieba.baidu.com/p/5626879744?pn=${x}`).then(r=>r.text())))).filter((x,i)=>parseInt($(x).find('.tP')[0].textContent)===i+1).map(x=>$(x).find('.d_post_content').toArray().reduce((d,x)=>{
const div=document.createElement('div')
div.innerHTML=x.innerHTML.replace(/<br>/g,'\n').replace(/&lt;/g,'<').replace(/&gt;/g,'>')
if(div.textContent.replace(/(\n| )/g,'').length>=50&&!div.textContent.includes('广告')&&!div.textContent.includes('免费'))return d+'\n'+div.textContent
else return d
},'').trim()).join('\n\n')
@maple3142
maple3142 / README.md
Last active April 26, 2018 14:06
從 FushionApp 的 apk 中匯出 .fas 檔

從 FushionApp 的 apk 中匯出 .fas

需求

  • 安裝 node.js
  • 會使用指令介面 (cmd,bash,...)

步驟

  1. 把這個 gist 下載成一個 zip 檔後解壓縮
  2. 在裡面執行 npm i
  3. 把目標 apk 放到同個資料夾
(function(global) {
'use strict'
const pjax={}
pjax._get=url=>{
return new Promise((res,rej)=>{
const xhr=new XMLHttpRequest()
xhr.open('GET', url)
xhr.onload=()=>res([xhr.responseText,xhr])
xhr.onerror=rej
xhr.send()
// outdated
// please heads for https://github.com/maple3142/ytdl
const axios = require('axios')
const parseQuery = s => {
const o = s
.split('&')
.map(x => x.split('='))
.reduce((p, c) => {