引用
https://www.cnblogs.com/aaronjs/archive/2012/06/30/2570970.html
Tampmonkey引入jQuery
// ==UserScript==
// @name 1688手機(jī)鏈接跳轉(zhuǎn)PC鏈接
// @namespace http://tampermonkey.net/
// @version 0.1
// @description when you click a link from mobile device, this code help you direct to the PC pages.
// @author You
// @match *m.1688.com/offer/*
// @icon https://www.google.com/s2/favicons?domain=1688.com
// @grant none
// @require https://cdn.staticfile.org/jquery/3.5.0/jquery.min.js
// @require https://cdn.staticfile.org/dompurify/2.0.10/purify.min.js
// @require https://cdn.staticfile.org/snap.svg/0.5.1/snap.svg-min.js
// ==/UserScript==
(function() {
$(function(){
alert($('body').html())
})
})();
- 常用語(yǔ)法
// 獲取瀏覽器地址
window.location.href;
// 正則匹配
var re = new RegExp();//RegExp是一個(gè)對(duì)象,和Aarray一樣
//但這樣沒有任何效果,需要將正則表達(dá)式的內(nèi)容作為字符串傳遞進(jìn)去
re =new RegExp("a");//最簡(jiǎn)單的正則表達(dá)式,將匹配字母a
re=new RegExp("a","i");//第二個(gè)參數(shù),表示匹配時(shí)不分大小寫
var re = /a/gi;
/*
g (全文查找)
i (忽略大小寫)
m (多行查找)
*/
*正則表達(dá)式
[a-z] // 匹配所有的小寫字母
[A-Z] // 匹配所有的大寫字母
[a-zA-Z] // 匹配所有的字母
[0-9] // 匹配所有的數(shù)字
[0-9\.\-] // 匹配所有的數(shù)字,句號(hào)和減號(hào)
[ \f\r\t\n] // 匹配所有的白字符
?g (全文查找)
?i (忽略大小寫)
?m (多行查找)
- 正則表達(dá)式應(yīng)用
"^\d+$" //非負(fù)整數(shù)(正整數(shù) + 0)
"^[0-9]*[1-9][0-9]*$" //正整數(shù)
"^((-\d+)|(0+))$" //非正整數(shù)(負(fù)整數(shù) + 0)
"^-[0-9]*[1-9][0-9]*$" //負(fù)整數(shù)
"^-?\d+$" //整數(shù)
"^\d+(\.\d+)?$" //非負(fù)浮點(diǎn)數(shù)(正浮點(diǎn)數(shù) + 0)
"^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮點(diǎn)數(shù)
"^((-\d+(\.\d+)?)|(0+(\.0+)?))$" //非正浮點(diǎn)數(shù)(負(fù)浮點(diǎn)數(shù) + 0)
"^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //負(fù)浮點(diǎn)數(shù)
"^(-?\d+)(\.\d+)?$" //浮點(diǎn)數(shù)
"^[A-Za-z]+$" //由26個(gè)英文字母組成的字符串
"^[A-Z]+$" //由26個(gè)英文字母的大寫組成的字符串
"^[a-z]+$" //由26個(gè)英文字母的小寫組成的字符串
"^[A-Za-z0-9]+$" //由數(shù)字和26個(gè)英文字母組成的字符串
"^\w+$" //由數(shù)字、26個(gè)英文字母或者下劃線組成的字符串
"^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$" //email地址
"^[a-zA-z]+://(\w+(-\w+)*)(\.(\w+(-\w+)*))*(\?\S*)?$" //url
/^(d{2}|d{4})-((0([1-9]{1}))|(1[1|2]))-(([0-2]([1-9]{1}))|(3[0|1]))$/ // 年-月-日
/^((0([1-9]{1}))|(1[1|2]))/(([0-2]([1-9]{1}))|(3[0|1]))/(d{2}|d{4})$/ // 月/日/年
"^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)$" //Emil
"(d+-)?(d{4}-?d{7}|d{3}-?d{8}|^d{7,8})(-d+)?" //電話號(hào)碼