Skip to content

Instantly share code, notes, and snippets.

View giser's full-sized avatar
🌴
On vacation

giser giser

🌴
On vacation
View GitHub Profile
@jimmywarting
jimmywarting / readme.md
Last active March 11, 2026 03:38
Cors proxies
Exposed headers
Service SSL status Response Type Allowed methods Allowed headers
@ikawka
ikawka / cloudflare-trace.js
Last active February 25, 2026 19:22
Trace current user's location via javascript with CloudFlare provided the /cdn-cgi/trace is enabled.
(function($){
$(function(){
$.ajax({
contentType: 'application/text; charset=utf-8',
crossBrowser: true,
type: 'GET',
url: '/cdn-cgi/trace',
}).done(function(d){
var data = d.replace(/[\r\n]+/g, '","').replace(/\=+/g, '":"');
data = '{"' + data.slice(0, data.lastIndexOf('","')) + '"}';
@337547038
337547038 / js获取滚动条的宽度
Created April 23, 2018 09:50
js获取滚动条的宽度
判断滚动条的需求在弹窗插件中使用比较多,当弹窗添加overflow: hidden时,如果页面比较长的话,添加这个属性之后页面会有晃动。
为了增强用户体验,通过判断是否有滚动条而添加 margin-left 属性以抵消 overflow: hidden 之后的滚动条位置。
判断是否有滚动条的方法
function hasScrollbar() {
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight);
}
计算滚动条宽度的方法
新建一个带有滚动条的 div 元素,通过该元素的 offsetWidth 和 clientWidth 的差值即可获得
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active January 30, 2026 14:23
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@JimLiu
JimLiu / ChatGPT-Translate-Long-Text.js
Last active April 8, 2024 07:26
使用ChatGPT自动分页翻译长文
// WARNING:此脚本仅做学习和演示用途,在不了解其用途前不建议使用
// 本脚本的用途是将输入内容分页,每次提取一页内容,编辑第二条消息,发送,然后收集结果
// 使用前,需要有两条消息,参考模板 https://chat.openai.com/share/17195108-30c2-4c62-8d59-980ca645f111
// 演示视频: https://www.bilibili.com/video/BV1tp4y1c7ME/?vd_source=e71f65cbc40a72fce570b20ffcb28b22
//
(function (fullText) {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const groupSentences = (fullText, maxCharecters = 2800) => {
const sentences = fullText.split("\n").filter((line) => line.trim().length > 0);