Basic Functions

自用函数 For wenku8++

Tính đến 20-08-2022. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyforks.org/scripts/449412/1083543/Basic%20Functions.js

Tác giả
PYUDNGwenku8-plus
Phiên bản
0.2
Đã tạo
12-08-2022
Đã cập nhật
20-08-2022
Size
10 KB
Giấy phép
GPL-license

自己写的常用函数

  • DoLog([LogLevel,] content[, logAsObject]): Log message or object to console with loglevel
  • $([this,] querySelector): querySelector
  • $All([this,] querySelector): querySelectorAll
  • $CrE([this,] tagName): createElement
  • copyProp(obj1, obj2, prop): copy prop form obj1 to obj2 if prop exist on obj1 as its own property
  • copyProps(obj1, obj2, props): copy All obj1's own properties to obj2
  • destroyEvent(e): Just stopPropagation and preventDefault
  • GMXHRHook(maxXHR = 5): Hook GM_xmlhttpRequest to make it only runs amount under maxXHR of xhrs at the same time
  • getUrlArgv(details): Get a url argument from lacation.href; Args: {url=location.href, name, dealFunc=((a)=>{return a;}), defaultValue=null} or 'name'
  • addStyle: Append a style text to document() with a <style> element
  • saveFile(dataURL, filename): Save dataURL to file
  • downloadFile(details): File download function; details looks like the detail of GM_xmlhttpRequest but need name as filename
  • getAPI(url = location.href): get '/' splited API array from a url
  • getHost(url = location.href): get host part from a url(includes '^https://', '/$')
  • AsyncManager(): Manage async tasks and call onfinish callback(if exist) when all tasks finished and finishEvent is true
  • polyfill_replaceAll(): A Simple String.prototype.replaceAll's polyfill
  • randint(min, max): random integer in range min -> max. Both min and max are included
  • delItem(arr, delIndex): remove an item from arr at delIndex
长期地址
遇到问题?请前往 GitHub 提 Issues。