函数库

公共函数库

ของเมื่อวันที่ 18-01-2022 ดู เวอร์ชันล่าสุด

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/438730/1009750/%E5%87%BD%E6%95%B0%E5%BA%93.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey to install this script.

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         函数库
// @namespace    https://hz.cn2down.com
// @version      0.1
// @description  公共函数库
// @author       zenghp2015
// @license MIT
// ==/UserScript==

(function() {
  'use strict';
 
 const libs = {
     
     getQuery: function () {
        const url = decodeURI(location.search); // 获取url中"?"符后的字串(包括问号)
        let query = {};
        if (url.indexOf("?") != -1) {
            const str = url.substr(1);
            const pairs = str.split("&");
            for(let i = 0; i < pairs.length; i ++) {
                const pair = pairs[i].split("=");
                query[pair[0]] = pair[1];
            }
        }
        return query ;  // 返回对象
    },

    getQueryValue: function (name) {
        const url = decodeURI(location.search); // 获取url中"?"符后的字串(包括问号)
        let query = {};
        if (url.indexOf("?") != -1) {
            const str = url.substr(1);
            const pairs = str.split("&");
            for(let i = 0; i < pairs.length; i ++) {
                const pair = pairs[i].split("=");
                if(pair[0] === name) return  pair[1]; // 返回 参数值
            }
        }
        return(false);
    }
 }
 
 window.cn2Libs = libs

})();