Skip to content

Instantly share code, notes, and snippets.

@pa001024
pa001024 / 1.js
Created September 28, 2019 09:00
midishow 下载脚本
//javascript:
function saveAs(link, filename) {
var i = document.createElement("a");
i.download = filename;
i.href = link;
i.target = "_blank";
var o = document.createEvent("MouseEvent");
o.initEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 0, null);
i.dispatchEvent(o);
}
@pa001024
pa001024 / saveas.js
Last active April 20, 2017 17:04
网页上JS导出文件经常要用的函数
function saveAs(link, filename = "download") {
var i = document.createElement("a");
i.download = filename;
i.href = link;
i.target = "_blank";
var o = document.createEvent("MouseEvent");
o.initEvent("click", !0, !0, window, 1, 0, 0, 0, 0, !1, !1, !1, !1, 0, null);
i.dispatchEvent(o);
};
'use strict';
// install: `npm install pofile xlsx`
const PO = require('pofile');
const XLSX = require('xlsx');
// settings
const xlsFile = "text_chn_2017-04-11.xlsm";
const newxlsFile = `text_chn_2017-04-11-new.xlsm`;
const poFile = "output.po";
const mode = "import"; // import or export
@pa001024
pa001024 / lajichaoxing.js
Last active May 18, 2016 16:08
垃圾超腥
var rdd = document.querySelector("#qqqq > iframe").contentDocument
.querySelector("iframe").contentDocument.querySelector("#reader param[name='flashvars']");
var logParam = decodeURIComponent(rdd.value.match(/&logParam=.+/).reduce(() => {}).substr(10));
logParam = JSON.parse(logParam);
delete logParam.isSendLog;
console.log("duration: " + logParam.duration);
function getEnc(playingTime, isdrag) {
function md5(string) {
@pa001024
pa001024 / comb_and_perm.go
Last active April 14, 2016 15:01
go 排列组合
package main
import (
"fmt"
)
func main() {
m := make([]int, 0, Fact(5))
nums := []int{1, 2, 7, 8}
Perm(nums, 4, func(v []int) {
@pa001024
pa001024 / doubanmov.js
Created February 27, 2016 04:33
自动生成文件名
javascript: void!function(v, n) {
var score = "[" + $('strong.rating_num').text() + "]";
var title = $('span[property="v:itemreviewed"]').text();
var mainname = title.split(" ")[0];
v = $(".subject").text().match(/又名: (.+)/);
var altername = (title.split(" ").slice(1).join(" ") + (!v ? "" : " / " + v[1])).split(" / ").reduce(function(a, b) {
return !a.match(/[^\x01-\xff]/) && a ? a : b
}).replace(/[:,!'"]| - /g, "").replace(/ +/g, ".");
var year = $('span.year').text().match(/\d+/)[0];
var size = "480p";
fs=require("fs");
var files = JSON.parse(fs.readFileSync("D:\\doc\\desktop\\game.x.json", "utf-8")).filter(a=>a.id<840);
var level1_filted = files.filter(a => a.source.match(/"[^"\\\n]*(?:\\.[^"\\\n]*)*"/));
// reduce each file strings into {id:xx,data:[?]}
var level2_reduced = level1_filted.reduce((du,entry) =>
{
var data = entry.source.match(/(?:log\()?"[^"\\]*(?:\\.[^"\\]*)*"/g)
.filter(a=>!a.startsWith("log"))
.map(_=>{try{_=JSON.parse(_)}catch(e){};return _||"fuck"})
@pa001024
pa001024 / fuckfourcolor.js
Last active June 27, 2016 00:43
i means, the fucking four color books in China is very ...........
// javascript:void (function(a,d){d=document.createElement('script');d.src=a;document.body.appendChild(d)})('//cdn.staticfile.org/jquery/1.11.1/jquery.min.js');
var tmlist = $("#hiddenTmIds").val();
var tkid = location.search.match(/tkid=.+(?=&)/).reduce(a => a).substr(5);
function fuckone(id, defer) {
var f = function(resolve, reject) {
$.get("/WebTraining/SubjectLibraryPractice/DoPractice.aspx?NodeType=K&tkid=" + tkid + "&mode=0&tm_id=" + id, function(data) {
var rex = /var m_divTmnr = "题目内容:(.+?)";[\s\S]+var m_lblBzda = '(.+?)';[\s\S]+var p_Options = '(.*?)';/g;
var m = rex.exec(data);
@pa001024
pa001024 / bookmark.js
Created December 19, 2015 03:14
doubandianyin
javascript:
void !function(v){var filename = "["+$('strong.rating_num').text()+"]"
+$('span[property="v:itemreviewed"]').text().split(" ")[0]+"."
+($('span[property="v:itemreviewed"]').text().split(" ").slice(1).join(" ")
+(!$(".subject").text().match(/又名: (.+)/)?"":
" / "+$(".subject").text().match(/又名: (.+)/)[1])).split(" / ")
.reduce(function(a,b){return a.match(/[^\x01-\xff]/)?b:a}
)
.replace(/[:,]| - /g,"").replace(/ +/g,".")+"."
+$('span.year').text().match(/\d+/)[0]+"."
javascript:var i=1,t=setInterval(function(o){o=document.createEvent("DeviceMotionEvent");o.initDeviceMotionEvent("devicemotion",!0,!0,null,{x:-24*i,y:-25*i,z:-26*i},null,20);window.dispatchEvent(o);i=-i},24)