Skip to content

Instantly share code, notes, and snippets.

@bmvpdxl
bmvpdxl / config.md
Created December 8, 2023 02:11
vscode配置类似webstorm中todo高亮
{"+__ruleListOf_auto switch":{"color":"#99dd99","defaultProfileName":"direct","format":"AutoProxy","lastUpdate":"2023-05-27T10:19:00.632Z","matchProfileName":"proxy","name":"__ruleListOf_auto switch","profileType":"RuleListProfile","revision":"186b05d1615","ruleList":"[AutoProxy 0.2.9]\n! Checksum: FzrwXOsUo2Kxse803GAd6A\n! Expires: 6h\n! Title: GFWList4LL\n! GFWList with EVERYTHING included\n! Last Modified: Fri, 19 May 2023 23:42:18 -0400\n!\n! HomePage: https://github.com/gfwlist/gfwlist\n! License: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt\n!\n! GFWList is unlikely to fully comprise the real\n! rules being deployed inside GFW system. We try\n! our best to keep the list up to date. Please\n! contact us regarding URL submission / removal,\n! or suggestion / enhancement at issue tracker:\n! https://github.com/gfwlist/gfwlist/issues/.\n\n!---------403/451/503/520 & URL Redirects---------\n!--ehentai\n|http://85.17.73.31/\n!--||adorama.com\n||afreecatv.com\n||agnesb.fr\n||akiba-web.com\n||altrec.c
@bmvpdxl
bmvpdxl / safari-nomodule.js
Created June 3, 2022 17:47 — forked from samthor/safari-nomodule.js
Safari 10.1 `nomodule` support
/*
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bmvpdxl
bmvpdxl / sortBy.js
Last active August 25, 2021 15:12
去重 & 排序
/**
* 根据给定排序
* @param arr
* @param iterateeArr iteratee数组, 元素需要是方法, 方法的参数是arr中的元素, 返回的值会在Array.prototype.sort compare函数中对比用
* @returns {*[]}
*/
function sortBy(arr = [], iterateeArr = []) {
if (iterateeArr.length === 0) {
return arr;
}
@bmvpdxl
bmvpdxl / Utils.js
Last active June 28, 2019 07:37
amazing function
// https://juejin.im/post/5cc55eb5e51d456e577f93f0
// 随机更改数组元素顺序,混淆数组
const shuffleArr = (arr) => arr.slice().sort(() => Math.random() - 0.5)
// 方便快捷创建特定大小的数组
const createArr = (n) => [...Array(n).keys()]
// 3 --> [0, 1, 2]
@bmvpdxl
bmvpdxl / scrollTop.js
Last active May 15, 2019 01:53
cross-browser compatibility for document currently scrolled. pageYOffset, window.scrollY, document.documentElement.scrollTop, document.body.scrollTop
// 完整兼容代码
// see detail: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY#Notes
var supportPageOffset = window.pageXOffset !== undefined;
var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
var x = supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
var y = supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
@bmvpdxl
bmvpdxl / date.js
Last active March 23, 2019 14:49
日期相关的
/**
* 获取月份的天数
* @param {*} month - 月份(1-12), 默认当前月
* @param {*} year - 年, 默认今年
*/
function getDaysInMonth(month=new Date().getMonth()+1, year=new Date().getFullYear()) {
return new Date(year, month, 0).getDate();
}
/**
@bmvpdxl
bmvpdxl / mouseevent&elementPosition.md
Created March 10, 2019 07:52
mouseevent&elementPosition

mouse event

属性名 说明
clientX/clientY 当前点击点距离浏览器显示窗口(游览器的显示页面内容的窗口大小(不包含工具栏、导航栏等等))的长度
offsetX/offsetY 事件对象与目标节点的内填充边(padding edge, 即不包含边框. 在边框上点击返回负值)的偏移量
screenX/screenY 事件对象距离相对于屏幕的偏移量(不局限于浏览器窗口)
pageX/pageY 相对于整个文档(包含已滚到窗口之外的距离)的偏移量
x/y clientX/clientY的别名
@bmvpdxl
bmvpdxl / getLocalIp.js
Created May 4, 2018 09:20
Get local ip in nodejs
// from source of https://github.com/JacksonTian/anywhere
var getIPAddress = function () {
var os = require('os');
var ifaces = os.networkInterfaces();
var ip = '';
for (var dev in ifaces) {
ifaces[dev].forEach(function (details) {
if (ip === '' && details.family === 'IPv4' && !details.internal) {
@bmvpdxl
bmvpdxl / isIE.js
Created May 3, 2018 06:48 — forked from gaborpinterweb/isIE.js
Detect IE with JavaScript #ie #edge #js #javascript
// Forked from https://codepen.io/gapcode/pen/vEJNZN
// Get IE or Edge browser version
var version = detectIE();
if (version === false) {
document.getElementById('result').innerHTML = '<s>IE/Edge</s>';
} else if (version >= 12) {
document.getElementById('result').innerHTML = 'Edge ' + version;
} else {