Skip to content

Instantly share code, notes, and snippets.

View Neboer's full-sized avatar
🍉
Workermelon

Neboer Neboer

🍉
Workermelon
View GitHub Profile
@Neboer
Neboer / PromisedGetElements.js
Last active March 19, 2023 00:43
This code piece can be used in Tempermonkey scripts. Execute it on page init and it will wait for dom until target element shows up. Then you can get the elements you requested and work with it.
// need piority: document-start
function waitForElm(selector_list) {
let result_list = new Array(selector_list.length).fill(null)
// request all elements in selector, if all elements are set, then return true.
function collect_selection() {
selector_list.forEach((value, index) => {
if (!result_list[index]) {
let search_result = document.querySelector(value);
if (search_result) result_list[index] = search_result
@Neboer
Neboer / DoSomethingEval.js
Created March 15, 2023 10:11
This javascript is copied from a bad website.
window.isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
var isIOS = -1 < navigator.userAgent.search(/iphone/gi),
isAndroid = -1 < navigator.userAgent.search(/(android|linux)/gi);
function ywglvbaj(window, document, navigator, ac) {
;;
window._N1_ZS = function() {
function n(e) {
for (var o, n, t, r = {}, c = "", i = [], a = 0, f = 0, l = 32, u = -1, s = String.fromCharCode; l++ < 126;) 39 != l && 92 != l && (r[s(l)] = f++);
for ("number" == typeof e && (e = h[e]), f = l = 0; l++ < e.length;)
@Neboer
Neboer / bilibili_video_screenshot.js
Last active September 5, 2023 14:27
给b站添加“截图”按钮的油猴脚本
'use strict';
// ==UserScript==
// @name BiliBili截图工具
// @namespace http://tampermonkey.net/
// @version 1.1
// @description 完全本地化的、在对bilibili视频进行截图的工具。
// @author Neboer
// @match https://www.bilibili.com/video/*
// @icon https://www.bilibili.com/favicon.ico
// @grant none
import simplematrixbotlib as botlib
from nio import RoomMemberEvent, rooms
from yaml import safe_load
from re import match
with open("config.yaml", "r", encoding="utf8") as config_file:
config = safe_load(config_file)
creds = botlib.Creds(config["target_server"], config["bot_username"], access_token=config["access_token"], session_stored_file=config["session_file"])
bot = botlib.Bot(creds)
@Neboer
Neboer / sls.py
Created August 13, 2022 22:57
sls,一个全平台支持的简单ls命令,主要用于解决Windows操作系统里没有合适的、支持终端编码输出的ls命令的问题。
import argparse
from pathlib import Path
import os
from os import scandir
from sys import stderr, exit
class PseudoDirEntry:
def __init__(self, path):
if not Path(path).exists():
raise FileNotFoundError
@Neboer
Neboer / WaterPouringPuzzleSolver.js
Created April 29, 2022 23:14
解决倒水小游戏的dfs方法。
// gameinfo
// n, target, capacity, result
function perform(state, src, dst, info) {
state[dst] += state[src]
if (state[dst] > info.capacity[dst]) {
state[src] = state[dst] - info.capacity[dst]
state[dst] = info.capacity[dst]
} else {
state[src] = 0
}
@Neboer
Neboer / nbtp.c
Last active July 21, 2022 08:22
nbtp is a simple C/C++ program to convert any binary file to a validate png picture use lodepng
#include "lodepng.h"
#include <math.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define max_buffer 0xFFFFFF
struct size
{
unsigned width;
@Neboer
Neboer / 1.git
Created September 29, 2018 03:28
MyFirstGit
dff