-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
anonymous
committed
May 5, 2024
1 parent
149fcb1
commit 1a05cd5
Showing
45 changed files
with
5,475 additions
and
920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# vim: set fenc=utf-8 ft=taskini: | ||
# see: https://github.com/skywind3000/asynctasks.vim/wiki/Task-Config | ||
|
||
# define a new task named "file-build" | ||
[file-build] | ||
|
||
# shell command, use quotation for filenames containing spaces | ||
# check ":AsyncTaskMacro" to see available macros | ||
command=npm run compileIntoSingleFile "$(VIM_FILEPATH)" | ||
|
||
# working directory, can change to $(VIM_ROOT) for project root | ||
cwd=$(VIM_FILEDIR) | ||
|
||
# output mode, can be one of quickfix and terminal | ||
# - quickfix: output to quickfix window | ||
# - terminal: run the command in the internal terminal | ||
output=quickfix | ||
|
||
# this is for output=quickfix only | ||
# if it is omitted, vim's current errorformat will be used. | ||
errorformat=%f:%l:%m | ||
|
||
# save file before execute | ||
save=1 | ||
|
||
|
||
[file-install] | ||
command:typescript=npm run installScript "$(VIM_FILEPATH)" | ||
cwd=$(VIM_FILEDIR) | ||
save=2 | ||
[file-reinstall] | ||
command:typescript=npm run compileIntoSingleFile "$(VIM_FILEPATH)" && npm run installScript "$(VIM_FILEPATH)" | ||
cwd=$(VIM_FILEDIR) | ||
save=2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable */ | ||
/* prettier-ignore */ | ||
// @ts-nocheck | ||
// noinspection JSUnusedGlobalSymbols | ||
// Generated by unplugin-auto-import | ||
export {} | ||
declare global { | ||
const UserScriptStorage: typeof import('./src/utils/storage')['UserScriptStorage'] | ||
const _debugger: typeof import('./src/utils/debug')['_debugger'] | ||
const awayFromBottom: typeof import('./src/utils/scroll')['awayFromBottom'] | ||
const download: typeof import('./src/utils/download')['download'] | ||
const enableAutoTurningToNextPage: typeof import('./src/utils/navigating')['enableAutoTurningToNextPage'] | ||
const enableHorizontalScroll: typeof import('./src/utils/scroll')['enableHorizontalScroll'] | ||
const enableMiddleClickToDownload: typeof import('./src/utils/download')['enableMiddleClickToDownload'] | ||
const getPathname: typeof import('./src/utils/navigating')['getPathname'] | ||
const inPage: typeof import('./src/utils/navigating')['inPage'] | ||
const isLeftclick: typeof import('./src/utils/download')['isLeftclick'] | ||
const isMiddleclick: typeof import('./src/utils/download')['isMiddleclick'] | ||
const isRecordWithAtLeastOneAddedHTMLElement: typeof import('./src/utils/observer')['isRecordWithAtLeastOneAddedHTMLElement'] | ||
const mutationObserver: typeof import('./src/utils/observer')['mutationObserver'] | ||
const nearlyScrolledToBottom: typeof import('./src/utils/scroll')['nearlyScrolledToBottom'] | ||
const onNearlyScrolledToBottom: typeof import('./src/utils/scroll')['onNearlyScrolledToBottom'] | ||
const openInTab: typeof import('./src/utils/navigating')['openInTab'] | ||
const redirectedFromAnotherTab: typeof import('./src/utils/navigating')['redirectedFromAnotherTab'] | ||
const scrollToBottom: typeof import('./src/utils/scroll')['scrollToBottom'] | ||
const scrollToBottomAndScrollBack: typeof import('./src/utils/scroll')['scrollToBottomAndScrollBack'] | ||
const selectElementAsync: typeof import('./src/utils/selectElementAsync')['default'] | ||
const wait: typeof import('./src/utils/wait')['default'] | ||
} | ||
// for type re-export | ||
declare global { | ||
// @ts-ignore | ||
export type { Response_GM_XMLHttpRequest } from 'src/types' | ||
import('src/types') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// ==UserScript== | ||
// @name Pager | ||
// @version 0.0.1 | ||
// @match https://cn.bing.com/search* | ||
// @match https://www.bing.com/search* | ||
// @grant none | ||
// @description | ||
// ==/UserScript== | ||
"use strict"; | ||
const _debugger = { | ||
on: false, | ||
enable() { | ||
this.on = true; | ||
}, | ||
disable() { | ||
this.on = false; | ||
}, | ||
log(...data) { | ||
this.on && console.log(data); | ||
}, | ||
logForce(...data) { | ||
console.log(data); | ||
}, | ||
}; | ||
|
||
/** | ||
* Promise-based `setTimeout` | ||
*/ | ||
async function wait(time) { | ||
function execute(resolve) { | ||
setTimeout(resolve, time); | ||
} | ||
return new Promise(execute); | ||
} | ||
|
||
function nearlyScrolledToBottom(offset = 1) { | ||
return window.innerHeight + Math.ceil(window.scrollY) + offset >= document.body.scrollHeight; | ||
} | ||
function onNearlyScrolledToBottom(callback, options) { | ||
const { offset = 1, cooldown = 100 } = { ...options }; | ||
let cooledDown = true; | ||
window.addEventListener("scroll", async () => { | ||
if (cooledDown && nearlyScrolledToBottom(offset)) { | ||
if (cooldown) { | ||
cooledDown = false; | ||
callback(cooldown); | ||
await wait(cooldown); | ||
cooledDown = true; | ||
} | ||
else { | ||
callback(cooldown); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
_debugger.enable(); | ||
onNearlyScrolledToBottom(() => { | ||
getNextPage(); | ||
}, { offset: 400 }); | ||
async function getNextPage() { | ||
const anchorToNextPage = [...document.querySelectorAll("a.sb_pagN")].at(-1); | ||
const response = await fetch(anchorToNextPage.href); | ||
const contentOfNextPage = await response.text(); | ||
const elementForNextPage = document.createElement("div"); | ||
elementForNextPage.innerHTML = contentOfNextPage; | ||
const resultList = elementForNextPage.querySelector("#b_results"); | ||
const relativeSearches = resultList.querySelector(".b_ans"); | ||
_debugger.log(relativeSearches); | ||
resultList.removeChild(relativeSearches); | ||
document.body.append(resultList); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// ==UserScript== | ||
// @name Playback rate controller | ||
// @version 0.0.2 | ||
// @match https://www.bilibili.com/video/* | ||
// @match https://www.bilibili.com/bangumi/play/* | ||
// @match https://www.bilibili.com/list/* | ||
// @grant none | ||
// @description | ||
// ==/UserScript== | ||
"use strict"; | ||
/** | ||
* Promise-based `setTimeout` | ||
*/ | ||
async function wait(time) { | ||
function execute(resolve) { | ||
setTimeout(resolve, time); | ||
} | ||
return new Promise(execute); | ||
} | ||
|
||
/** | ||
* @param options.intervalOfRetry * Will retry at `a later time` if the element is null(e.g. not loaded in page yet) | ||
* @warn This may cause an observer relying on the element to not work properly | ||
* @default 1000 | ||
*/ | ||
async function selectElementAsync(selectors, options) { | ||
const { intervalOfRetry = 1000, parent = document, expectingTheElementToExist = true, patient = false, } = { ...options }; | ||
let timesTried = 0; | ||
while (true) { | ||
if (expectingTheElementToExist && timesTried === 10) { | ||
const prompt = `\`selectElementAsync\` for "${selectors}" failed ${timesTried} times`; | ||
if (patient) { | ||
console.info(prompt); | ||
} | ||
else { | ||
console.warn(prompt); | ||
} | ||
} | ||
timesTried += 1; | ||
const element = parent.querySelector(selectors); | ||
if (element === null) { | ||
await wait(intervalOfRetry); | ||
} | ||
else { | ||
return element; | ||
} | ||
} | ||
} | ||
|
||
const videoElement = await selectElementAsync(".bpx-player-video-wrap video"); | ||
const video = { | ||
get playbackRate() { | ||
return videoElement.playbackRate; | ||
}, | ||
set playbackRate(rate) { | ||
videoElement.playbackRate = rate; | ||
}, | ||
togglePlayBackRate(rate1, rate2) { | ||
videoElement.playbackRate = videoElement.playbackRate === rate1 ? rate2 : rate1; | ||
}, | ||
basePlaybackRate: videoElement.playbackRate, | ||
toggleBasePlayBackRate(rate1, rate2) { | ||
this.basePlaybackRate = this.basePlaybackRate === rate1 ? rate2 : rate1; | ||
}, | ||
}; | ||
enableTogglingPlaybackRate(); | ||
enableHoldingDownToControlPlaybackRate(); | ||
function enableTogglingPlaybackRate() { | ||
const presetOfRates = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||
window.addEventListener("keydown", (event) => { | ||
if (presetOfRates.includes(Number(event.key))) { | ||
video.togglePlayBackRate(Number(event.key), video.basePlaybackRate); | ||
return; | ||
} | ||
switch (event.key) { | ||
case "s": { | ||
video.toggleBasePlayBackRate(1, 2); | ||
break; | ||
} | ||
default: | ||
return; | ||
} | ||
}, true); | ||
} | ||
function enableHoldingDownToControlPlaybackRate() { | ||
window.addEventListener("keydown", (event) => { | ||
switch (event.key) { | ||
case "a": { | ||
video.playbackRate = 4; | ||
break; | ||
} | ||
default: | ||
return; | ||
} | ||
}, true); | ||
window.addEventListener("keyup", (event) => { | ||
switch (event.key) { | ||
case "a": | ||
video.playbackRate = video.basePlaybackRate; | ||
break; | ||
default: | ||
return; | ||
} | ||
}, true); | ||
} | ||
// |
Oops, something went wrong.