Basic Functions

自用函数

Dit script moet niet direct worden geïnstalleerd - het is een bibliotheek voor andere scripts om op te nemen met de meta-richtlijn // @require https://update.greasyfork.org/scripts/449412/1122880/Basic%20Functions.js

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey, Greasemonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Violentmonkey.

Voor het installeren van scripts heb je een extensie nodig, zoals Tampermonkey of Userscripts.

Voor het installeren van scripts heb je een extensie nodig, zoals {tampermonkey_link:Tampermonkey}.

Voor het installeren van scripts heb je een gebruikersscriptbeheerder nodig.

(Ik heb al een user script manager, laat me het downloaden!)

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een extensie nodig, zoals {stylus_link:Stylus}.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

Voor het installeren van gebruikersstijlen heb je een gebruikersstijlbeheerder nodig.

(Ik heb al een beheerder - laat me doorgaan met de installatie!)

Maker
PYUDNG en wenku8-plus
Versie
0.8
Gemaakt op
12-08-2022
Bijgewerkt op
30-11-2022
Grootte
15,8 KB
Licentie
GPL-license

自己写的常用函数

  • DoLog([LogLevel,] content[, trace]): 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=Object.keys(obj1)): copy All given properties from obj1 to obj2
  • clearChildNodes(elm): remove all childNodes of given element
  • 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
  • replaceText(str, replacer): replace str patterns with replacer, without replacing already replaced texts
  • escJsStr(str, quotes='\'"`'): escape str into javascript written format
  • parseArgs(args, rules, defaultValues=[]): sort and deal the given args array
  • delItem(arr, delIndex): remove an item from arr at delIndex
  • Err(msg, type): throws an Error/TypeError with given msg based on given type