加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
index.old.html 56.79 KB
一键复制 编辑 原始数据 按行查看 历史
Lemon399 提交于 2021-11-22 20:37 . 5.1 Beta 8 21112220: 适配 CodeCheck
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#2b75c4">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self'; font-src *; connect-src 'self'; media-src 'none'; object-src 'none'; child-src 'none'; frame-src 'none'; worker-src 'self'; form-action 'self'; upgrade-insecure-requests; block-all-mixed-content; base-uri 'none';">
<title>Useragent 生成</title>
<script>
const uaData = {
base:{},
apps:{},
flag:{},
count:{},
text:{},
tagtext:{},
tagfind:{},
index:"",
jslist:[],
touch:"ontouchend" in document,
stor:{
apps:{},
flag:{}
},
storKey:"userAgentData",
设置:{
代码版本:"5.0 Beta 9",
基础默认:1,
数字记号:"#",
标签筛选开启:"#00ad46",
数据未保存:"orange",
输入框检查:[
"lightgray", // 未检查
"green", // 检查成功
"orange", // 检查失败
"red", // 数据为空
],
测试模式:false,
前置记号:"^",
无缝记号:"~",
}
};
</script>
<style>
:focus {
outline: none;
}
body {
font-size: 16px;
}
textarea {
color: black;
font-family: monospace;
border: 1px solid lightgray;
border-radius: 10px;
padding: 5px;
display: block;
}
body > div {
margin: 0 .5em;
}
.none,
.sel_none,
.tag_none {
display: none !important;
}
p {
margin: 1px;
}
a {
text-decoration: none;
color: black;
font-family: monospace;
margin: 0 1px;
font-size: .7em;
width: .5em;
height: 1.1em;
line-height: 1.1em;
font-weight: 600;
}
noscript {
color: lightgray;
text-align: center;
z-index: 10;
font-size: 4em;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: white;
font-weight: bold;
margin: 0;
}
#base,#mode,#app {
border: 1px solid lightgray;
border-radius: 10px;
overflow: hidden;
display: -webkit-box;
display: flex;
}
#base,#searchbox,#app {
margin-bottom: 4px;
}
.win {
font-size: 1em;
position: absolute;
top: 0;
left: 0;
background: rgba(160,210,255,0.6);
margin: 0;
-webkit-box-shadow: 0 0 10px dodgerblue;
box-shadow: 0 0 10px dodgerblue;
-webkit-backdrop-filter: blur(10px);
backdrop-filter: blur(10px);
}
#classBox,.classBox {
padding: 3px;
border-radius: 10px;
}
#classBox .flag,
.classBox .sflag {
padding: 0 4px;
margin: 0 2px;
}
#classBox input,
.classBox input {
display: none;
}
.setHead {
background: lightgray;
font-size: .75em;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-align: center;
align-items: center;
width: 6.5em;
}
#ajump {
display: -webkit-box;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
flex-flow: column;
-webkit-box-pack: justify;
justify-content: space-between;
width: 7px;
background-color: lightgray;
margin: 0;
padding: 3px;
}
#baseopt,#modeopt {
line-height: 22px;
width: 100%;
}
#baseopt {
display: grid;
grid-template-columns: repeat(4, -webkit-max-content);
grid-template-columns: repeat(4, max-content);
grid-template-rows: repeat(2, -webkit-max-content);
grid-template-rows: repeat(2, max-content);
}
#modeopt {
display: -webkit-box;
display: flex;
-webkit-box-pack: justify;
justify-content: space-between;
}
#modeopt > div {
display: -webkit-box;
display: flex;
}
#base label,
#mode label,
#classBox label,
.classBox label,
#tclsbox {
display: -webkit-inline-box;
display: inline-flex;
}
#app label {
margin-left: .5em;
display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
}
#app label i {
margin-left: .25em;
color: lightgray;
}
.CaseHead {
font-size: .75em;
font-weight: bold;
background: darkgray;
padding-left: 5px;
}
.sideBar {
width: 15px;
background-color: lightgray;
padding: 3px;
}
div.sideBar > div {
text-align: center;
font-size: .5em;
height: 1.6em;
line-height: 1.6em;
}
div.sideBar > div:last-of-type {
position: absolute;
width: 1.5em;
height: 1.5em;
line-height: 1.5em;
text-align: center;
-webkit-transform: translate3d(-1.5em, 0, 0);
transform: translate3d(-1.5em, 0, 0);
font-size:2em;
opacity:0;
-webkit-transition: opacity .3s ease, top .1s linear;
-o-transition: opacity .3s ease, top .1s linear;
transition: opacity .3s ease, top .1s linear;
color:#eee;
background-color: rgba(0, 0, 0, 0.4);
border-radius:100%;
}
#app_container {
overflow-y: scroll;
height: calc(1.5em * 14.5);
width: 100%;
}
#action,#action2,#action3,#addbtn,.savebtn {
text-align: center;
display: -webkit-box;
display: flex;
-webkit-box-pack: justify;
justify-content: space-between;
}
#action {
margin: 0 .5em;
}
.orig-box {
display: none;
}
.new-style {
background-color:white;
border:1px solid rgba(0,0,0,0.15);
border-radius:100%;
width:16px;
height:16px;
line-height:16px;
}
.new-radio.new-style {
margin: 2px;
display:-webkit-box;
display:flex;
}
.orig-box:checked + .new-style.new-radio:after {
-webkit-transform:scale(.8);
transform:scale(.8);
}
.new-check.new-style {
margin: 3px 3px 1px auto;
border-radius:0;
display:inline-block;
}
.orig-box:checked + .new-style {
border: 1px solid #2b75c4;
}
.orig-box:checked + .new-style:after {
background-color:#2b75c4;
border-radius:100%;
content:"";
height:12px;
width:12px;
display: -webkit-box;
display: flex;
margin: auto;
align-self: center;
}
.orig-box:checked + .new-check.new-style::after {
width: 5px;
height: 9px;
border-color: #2b75c4;
border-style: solid;
border-width: 0 3px 3px 0;
border-radius: 0;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
background-color: transparent;
}
input[type=checkbox] {
float: right;
}
button {
background-color:#2b75c4;
border-radius:6px;
border:1px solid transparent;
color:#ffffff;
font-size:.75em;
font-weight:bold;
padding:3px 1em;
margin:0 2px;
}
button:focus {
background-color:#4e92d0;
}
button:hover {
background-color:#1e62d0;
}
#searchbox {
position: relative;
}
#search {
border: 1px solid lightgray;
color: black;
width: calc(100% - 1.1em);
font-family: monospace;
border-radius: 20px;
padding: 0 6px;
display: block;
}
#version {
font-size: .5em;
color: lightgray;
float: right;
}
#nulltext {
font-size: 2em;
color: lightgray;
margin: auto;
width: 9em;
text-align: center;
}
#nulltext {
line-height: calc(1.5em * 7.25);
}
.flag {
font-size: .75em;
border-radius: 5px;
margin: 0 2px;
padding: 1px 5px;
vertical-align: 2px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
#addtype {
text-align: center;
margin: auto;
font-size: .9em;
}
.atab > *,
#addbtn,
#addsave > *,
#action2 > *,
#action3 > *,
#classBox,
#useragent {
margin: 3px;
}
.classPart > * {
margin: 3px 0;
}
.atab > label,
.classPart > label {
display: -webkit-box;
display: flex;
}
#addtype > label,
.atab > div > label {
display: -webkit-inline-box;
display: inline-flex;
vertical-align: middle;
line-height: 1.25em;
}
.atab > label strong,
.classPart > label strong,
.atab div p {
width: 20%;
min-width:5em;
margin: 0 .25em;
font-size: .9em;
}
.classPart > label strong {
margin: 0 .45em 0 calc(.25em - 3px);
}
.atab > label input,
.classPart > label input {
border: 1px solid transparent;
color: black;
padding: 0 6px;
display: block;
width: 80%;
min-width: 14em;
border-radius: 20px;
}
.atab div p,
#addsave div p {
display: inline-block;
font-weight: bold;
}
#addui {
padding: 0;
width: -webkit-min-content;
width: -moz-min-content;
width: min-content;
}
#openNew {
width: auto;
padding: 0 5px !important;
font-size: 16px;
}
.msel {
color: white;
background: #2b75c4;
width: 80%;
min-width: 14em;
border-radius: 20px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
padding: 0 8px 2px;
}
@-webkit-keyframes toast {
0% {
opacity: 0%;
}
35% {
opacity: 100%;
}
85% {
opacity: 100%;
}
100% {
opacity: 0%;
}
}
@keyframes toast {
0% {
opacity: 0%;
}
35% {
opacity: 100%;
}
85% {
opacity: 100%;
}
100% {
opacity: 0%;
}
}
#toast {
position: absolute;
left: 0;
right: 0;
bottom: 10%;
width: -webkit-max-content;
width: -moz-max-content;
width: max-content;
margin: 0 auto;
display: none;
border-radius: 20px;
padding: .5em 1em;
font-size: .75em;
font-weight: bold;
background-color: rgba(0,0,0,0.8);
color: white;
text-align: center;
z-index: 10;
}
.toasting {
display: block !important;
-webkit-animation: toast 3s;
animation: toast 3s;
}
.savebtn button {
width: 28%;
}
.titlebar {
width: 100%;
display: -webkit-box;
display: flex;
color: black;
font-size: .75em;
font-weight: bold;
}
.title {
padding: 3px 7px;
width: 100%;
background-color: transparent;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.win .close {
background-color: rgba(255,0,0,0.6);
font-size: 1em;
border-radius: 0;
border: 0;
margin: 0;
width: 5em;
}
.win .close:hover {
background-color: rgba(140,0,0,0.6);
}
.win .close:focus {
background-color: rgba(255,128,128,0.6);
}
@-webkit-keyframes load-finish {
0% {
opacity: 100%;
}
100% {
opacity: 0%;
}
}
@keyframes load-finish {
0% {
opacity: 100%;
}
100% {
opacity: 0%;
}
}
.finish {
-webkit-animation: load-finish 1s;
animation: load-finish 1s;
}
#load {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
z-index: 9;
background-color: white;
opacity: 100%;
margin: 0;
}
#loadstr,#browstr {
max-width: 80%;
margin: 0 auto;
margin-top: 1em;
font-size: 1.5em;
font-weight: bold;
text-align: center;
color: lightgray;
}
#browstr {
margin-top: .5em;
font-size: 1.25em;
}
#tclsbox {
float: right;
margin: 2px 0;
padding: 0 5px;
}
#tkey {
padding: 0;
border: none;
height: 100%;
}
#tkds {
width: 80%;
border-radius: 20px;
font-size: 13.3333px;
min-width: 14em;
background: white;
border: 1px solid transparent;
padding: 0 6px;
}
#tkds > span {
display: block;
overflow: hidden;
height: 100%;
}
#stordata {
width: -webkit-fill-available;
width: -moz-available;
}
#issues {
margin: 0 3px;
background-color: cornflowerblue;
border-radius: 5px;
color: white;
overflow-y: scroll;
max-height: 8em;
}
.issue {
margin: 2px .5em;
padding: 5px;
font-size: .85em;
font-weight: bold;
border: solid rgba(255,255,255,0.5);
border-width: 0;
border-top-width: 1px;
}
#issueHead {
border: none;
padding: 0 5px;
font-size: .75em;
font-weight: normal;
}
@media only screen and (min-width: 360px) {
#baseopt,#modeopt {
padding: 3px 0;
}
#modeopt button {
padding: 2px 3px;
}
textarea {
height: 146px;
width: 94%;
}
#ua {
width: 80%;
top: 40%;
left: 8.5%;
}
#class {
width: 65%;
}
#addui, #class {
top:10px;
left:10px;
}
#stordata {
height: 80px;
}
}
@media only screen and (min-width: 600px) {
body {
width: 500px;
margin: 10px auto;
}
#baseopt {
padding: 6px;
line-height: 19px;
}
#modeopt {
padding-left: 6px
}
#modeopt button {
padding: 3px .5em;
}
textarea {
height: 10em;
width: 97%;
}
#ua {
width: 40em;
top: 6em;
left: auto;
margin-left: -5em;
}
#class {
width: 24em;
top: 5px;
left: auto;
margin-left: 4em;
}
#addui {
left: auto;
top: 4em;
margin-left: 5em;
}
}
@media (prefers-color-scheme: dark) {
body {
-webkit-filter: hue-rotate(180deg) invert(1);
filter: hue-rotate(180deg) invert(1);
background-color: black;
}
#version {
color: black;
}
.win {
-webkit-backdrop-filter: none;
backdrop-filter: none;
}
}
</style>
</head>
<body>
<div id="base">
<div class="setHead"><p>基础 UA</p></div>
<div id="baseopt"></div>
</div>
<div id="mode">
<div class="setHead"><p>生成模式</p></div>
<div id="modeopt">
<div>
<label for="gen" tabindex="0" onkeydown="uaCode.util.check()">
<input id="gen" type="radio" name="mode" value="gen" class="orig-box" checked>
<span class="new-style new-radio"></span>生成
</label>
<label for="add" tabindex="0" onkeydown="uaCode.util.check()">
<input id="add" type="radio" name="mode" value="add" class="orig-box">
<span class="new-style new-radio"></span>追加
</label>
</div>
<div>
<button id="openNew" onclick="uaCode.open(uaCode.util.$(false,'#addui'))">+</button>
<button id="openClass" onclick="uaCode.open(uaCode.util.$(false,'#class'))">标签筛选</button>
<button onclick="uaCode.open(uaCode.util.$(false,'#ua'))">打开窗口</button>
</div>
</div>
</div>
<div id="searchbox">
<p id="version"></p>
<label for="search" class="none">在此输入搜索 APP ...</label>
<input id="search" name="search" type="text" placeholder="在此输入搜索 APP ..." oninput="uaCode.filter.app(this.value)">
</div>
<div id="app">
<div id="app_container">
<p id="nulltext" class="none">什么都没找到 T_T</p>
</div>
<p id="ajump" class="none"></p>
</div>
<div id="action">
<button onclick="(()=>{window.location.href='https://gitee.com/lemon399/user-agent-share-page/blob/master/README.md'})()">帮助</button>
<button onclick="uaCode.util.$_('app').forEach( check => { check.checked = false; })">清空选择</button>
<button onclick="uaCode.filter.sel(this)">列出已选</button>
<button onclick="uaCode.gen()">生成 UA</button>
</div>
<div id="ua" class="none win">
<div class="titlebar">
<div class="title drag">UA 窗口</div>
<button class="close" onclick="this.parentNode.parentNode.classList.add('none')">关闭</button>
</div>
<label for="useragent" class="none">UA 编辑框</label>
<textarea id="useragent" placeholder="你想要的在这儿 ^_^" oninput="uaCode.check()"></textarea>
<div id="issues"></div>
<div id="action2">
<button onclick="(()=>{uaCode.util.$(false,'#useragent').value = '';})()">清空</button>
<button onclick="(()=>{uaCode.util.$(false,'#useragent').select();document.execCommand('copy');})()">复制</button>
</div>
</div>
<div id="class" class="none win">
<div class="titlebar">
<div class="title drag">标签筛选</div>
<button class="close" onclick="this.parentNode.parentNode.classList.add('none')">关闭</button>
</div>
<div id="classBox"></div>
<div id="action3">
<button onclick="(()=>{uaCode.util.$(true,'#classBox input:not(:checked)').forEach( box => { box.checked = true; uaCode.tagClick(box.parentNode.id,true);});})()">恢复</button>
<button onclick="(()=>{uaCode.util.$(true,'#classBox input').forEach( box => { box.checked = (box.checked===true) ? false : true; uaCode.tagClick(box.parentNode.id,true);});})()">反选</button>
</div>
</div>
<div id="addui" class="none win">
<div class="titlebar">
<div class="title drag">添加项目</div>
<button class="close" onclick="this.parentNode.parentNode.classList.add('none')">关闭</button>
</div>
<div id="addtype">
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="Raapp" type="radio" name="atype" value="aapp" class="orig-box" onchange="uaCode.aform.switchCard()" checked>
<span class="new-style new-radio"></span>APP
</label>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="Rqapp" type="radio" name="atype" value="qapp" class="orig-box" onchange="uaCode.aform.switchCard()">
<span class="new-style new-radio"></span>快应用
</label>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="Ratag" type="radio" name="atype" value="atag" class="orig-box" onchange="uaCode.aform.switchCard()">
<span class="new-style new-radio"></span>标签
</label>
</div>
<div id="addtable">
<div id="aappt" class="atab">
<label id="akeyl"><strong>标识</strong>
<input id="akey" type="text" name="aapp" placeholder="首字母对应名称拼音首字母" oninput="uaCode.aform.check(false)"/>
</label>
<label id="asell" class="none"><strong>标识</strong>
<select id="asel" class="msel" onchange="uaCode.aform.modify()">
<option selected hidden disabled value="">请选择要修改的项目...</option>
</select>
</label>
<label><strong>名称</strong>
<input id="atext" type="text" name="aapp">
</label>
<div id="apre">
<p>前置</p>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="apret" type="radio" name="apre" value="true" class="orig-box" onchange="uaCode.aform.switchBoth()">
<span class="new-style new-radio"></span>
</label>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="apref" type="radio" name="apre" value="false" class="orig-box" onchange="uaCode.aform.switchBoth()" checked>
<span class="new-style new-radio"></span>
</label>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="apreb" type="radio" name="apre" value="both" class="orig-box" onchange="uaCode.aform.switchBoth()">
<span class="new-style new-radio"></span>前后都有
</label>
</div>
<div id="afol">
<p>无缝</p>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="afolt" type="radio" name="afol" value="true" class="orig-box">
<span class="new-style new-radio"></span>
</label>
<label tabindex="0" onkeydown="uaCode.util.check()">
<input id="afolf" type="radio" name="afol" value="false" class="orig-box" checked>
<span class="new-style new-radio"></span>
</label>
</div>
<label class="acont1"><strong>关键字</strong>
<input id="acont1" type="text" name="acont1"/>
</label>
<label class="acont2 none"><strong>前置关键字</strong>
<input id="acont2a" type="text" name="acont2"/>
</label>
<label class="acont2 none"><strong>后置关键字</strong>
<input id="acont2b" type="text" name="acont2"/>
</label>
<div id="acls">
<div id="aclsbox" class="classBox"></div>
<div id="aclsboxt" class="classPart">
<label id="aclsboxl" class="none"><strong>自定义标签</strong>
<input id="athirdt" type="text" name="athird"/>
</label>
</div>
</div>
</div>
<div id="qappt" class="atab none">
<label id="qkeyl"><strong>标识</strong>
<input id="qkey" type="text" name="qapp" placeholder="首字母对应名称拼音首字母" oninput="uaCode.aform.check(false)"/>
</label>
<label id="qsell" class="none"><strong>标识</strong>
<select id="qsel" class="msel" onchange="uaCode.aform.modify()">
<option selected hidden disabled value="">请选择要修改的项目...</option>
</select>
</label>
<label><strong>名称</strong>
<input id="qtext" type="text" name="qapp"/>
</label>
<label><strong>平台</strong>
<input id="qcont1" type="text" name="qcont"/>
</label>
<label><strong>来自</strong>
<input id="qcont2" type="text" name="qcont"/>
</label>
<label><strong>应用</strong>
<input id="qcont3" type="text" name="qcont"/>
</label>
<div id="qcls">
<div id="qclsbox" class="classBox"></div>
<div id="qclsboxt" class="classPart">
<label id="qclsboxl" class="none"><strong>自定义标签</strong>
<input id="qthirdt" type="text" name="qthird"/>
</label>
</div>
</div>
</div>
<div id="atagt" class="atab none">
<label id="tkeyl"><strong>标识</strong>
<div id="tkds">
<div id="tclsbox" class="flag"></div>
<span>
<input id="tkey" type="text" name="atag" placeholder="数字和英文字母" oninput="uaCode.aform.check(false)"/>
</span>
</div>
</label>
<label id="tsell" class="none"><strong>标识</strong>
<select id="tsel" class="msel" onchange="uaCode.aform.modify()">
<option selected hidden disabled value="">请选择要修改的项目...</option>
</select>
</label>
<label><strong>名称</strong>
<input id="ttext" type="text" name="atag" onchange="uaCode.aform.updateFlagPreview()"/>
</label>
<label><strong>背景</strong>
<input id="tbgc" type="color" name="atag" onchange="uaCode.aform.updateFlagPreview()"/>
</label>
<label><strong>文字</strong>
<input id="tfgc" type="color" name="atag" onchange="uaCode.aform.updateFlagPreview()"/>
</label>
</div>
</div>
<div id="addbtn">
<button id="aok" onclick="uaCode.aform.add()">加入</button>
<button onclick="uaCode.aform.clear()">清空表单</button>
<button id="anew" onclick="uaCode.aform.switchModify()">管理</button>
<button onclick="uaCode.aform.del()">删除</button>
</div>
<div id="addsave">
<label for="stordata" class="none">复制到这里就可以导入啦</label>
<textarea id="stordata" placeholder="复制到这里就可以导入啦"></textarea>
<div class="savebtn">
<button id="ssave" onclick="uaCode.lsb.save()">保存数据</button>
<button onclick="(()=>{uaCode.util.$(false,'#stordata').select();document.execCommand('copy');})()">复制内容</button>
<button onclick="(()=>{uaCode.util.$(false,'#stordata').value = '';})()">清空内容</button>
</div>
<div class="savebtn">
<button onclick="uaCode.lsb.import()">导入数据</button>
<button onclick="uaCode.lsb.export()">导出数据</button>
<button onclick="uaCode.lsb.clear()">清空存储</button>
</div>
</div>
</div>
<div id="toast" onanimationend="this.classList.remove('toasting')"></div>
<div id="load" onanimationend="this.classList.add('none')">
<p id="loadstr">正在加载...</p>
<p id="browstr">
这个页面至少需要:<br>
Chrome 51<br>
Edge 79<br>
Firefox 52<br>
Safari 11<br>
Opera 38<br>
不支持 Internet Explorer !
</p>
</div>
<noscript>亲,打开 JavaScript 才能工作哟!</noscript>
<script>
const uaCode = (() => {
let lab,cas,lah,ntx,loc,pos=[0,0];
function $(all,sel) {
return (all) ? document.querySelectorAll(sel) : document.querySelector(sel);
}
function $_(name) {
const list = $(true,`input[name="${name}"]:checked`);
return list.length === 1 && list[0].type === "radio" ? list[0] : list;
}
function _(ele,del,nclass) {
if (del) {
ele.classList.remove(nclass);
} else {
ele.classList.add(nclass);
}
}
function getUpperHead(word) {
const temp = word.slice(0,1).toUpperCase();
return /^[A-Z]$/u.test(temp) ? temp : uaData.设置.数字记号;
}
function scanAll() {
let found = 0;
lah.forEach( ele => {
if (window.getComputedStyle(ele).display!=="none") {
found += 1;
}
});
return found;
}
function scanForHead() {
cas.forEach( ele => {
let found = 0;
lab.forEach( la => {
if (getUpperHead(la.id) === ele.innerHTML && window.getComputedStyle(la).display !== "none") {
found += 1;
}
});
_(ele,found>=1,"none");
});
}
function tagConv(clas,fro,to) {
if (clas.slice(0,1)==="_") {
return (to) ? clas.slice(1) : "third" ;
} else if (fro===to) {
return clas;
} else {
return (fro) ? uaData.tagfind[clas] : uaData.flag[clas][0];
}
}
function toast(text) {
if (!window.webmx && window.mbrowser) {
window.mbrowser.showToast(text);
} else if (!window.alook && !window.webmx && !window._obj && window.via) {
window.via.toast(text);
} else if (window._obj) {
window._obj.toast(text);
} else if (window.H5EXT) {
window.H5EXT.cmd(99,text);
} else if (window.meta) {
window.meta.toast(text,3,null);
} else if (window.mx_browser_obj) {
window.mx_browser_obj.showtip(text);
} else if (window.JSInterface) {
window.JSInterface.syslog(text);
} else {
const toast = $(false,"#toast");
toast.innerHTML = text;
toast.className = "toasting";
}
}
function spaceChecked(e) {
if(!e) {
e = event;
}
switch (e.code) {
case "Space":
case "Enter":
e.target.control.checked = true;
break;
default:
return;
}
}
function genUA() {
const baseUA = $_("mode").value === "add" ?
$(false,"textarea").value :
uaData.base[$_("base").value].content,
midSpace = /.+\s.+/u;
let prefixUA = "",
preFollowUA = "",
suffixUA = " ",
sufFollowUA = "";
$_("app").forEach( app => {
const appo = uaData.apps[app.value];
if (typeof appo.content === "object") {
if (appo.content.qBasic!==undefined) {
appo.content = `${appo.content.qBasic} ${appo.content.qString} (${JSON.stringify({
packageName: appo.content.qFrom,
type: "url",
extra: {
scene: "recommend"
}
})})`;
}
}
if (appo.prefix) {
if (appo.followed) {
preFollowUA = midSpace.test(appo.content) ?
appo.content + preFollowUA :
preFollowUA + appo.content ;
} else {
prefixUA = `${appo.content} ${prefixUA}`;
}
} else if (appo.content instanceof Array) {
if (appo.followed) {
preFollowUA = midSpace.test(appo.content[0]) ?
appo.content[0] + preFollowUA :
preFollowUA + appo.content[0] ;
sufFollowUA = midSpace.test(appo.content[1]) ?
sufFollowUA + appo.content[1] :
appo.content[1] + sufFollowUA ;
} else {
prefixUA = `${appo.content[0]} ${prefixUA}`;
suffixUA += `${appo.content[1]} `;
}
} else {
if (appo.followed) {
sufFollowUA = midSpace.test(appo.content) ?
sufFollowUA + appo.content :
appo.content + sufFollowUA ;
} else {
suffixUA += `${appo.content} `;
}
}
});
$(false,"textarea").value = prefixUA + preFollowUA + baseUA + sufFollowUA + suffixUA;
issuesCheck();
openWin($(false,"#ua"));
}
function makeIssue(issue,head) {
let p = document.createElement('p');
p.className = "issue";
if (head) { p.id = 'issueHead'; }
p.innerHTML = issue;
$(false,'#issues').appendChild(p);
}
function cleanIssue() {
$(true,'.issue').forEach( i => {
$(false,'#issues').removeChild(i);
});
}
function issuesCheck() {
const ua = $(false,"textarea").value,
issue = [
[ // #1 百度 页面 确认框
( ua.includes('baiduboxapp/') && (
/Android[^\s\)]* +[^\)]*\)+?/u.test(ua) || ( ver = /baiduboxapp\/\d*/.exec(ua)[0].replace('baiduboxapp/',''),
ver === '' || ver >= 4 ))),
'此 UA 可能会导致 百度部分页面 加载时弹出 确认/取消 对话框'
],[ // #2 城通 下载按钮 失效
ua.includes('baidu'),
'此 UA 可能会导致大部分 城通网盘 下载按钮 失效'
],[ // #3 iPhone 下载 APP 跳到 AppStore
( ua.includes('iPhone') && ua.includes('AppleWebKit') ),
'此 UA 可能会导致 百度搜索 下载 APP 跳转到苹果的 AppStore'
],[ // #4 腾讯视频 页面 确认框
( ua.includes('Android') && ua.includes('qqnews') ),
'此 UA 可能会导致 腾讯视频播放页面 加载时弹出 确认/取消 对话框'
],[ // #5 蓝奏云 mtt: 确认框
( /\(.*Android.*\)/.test(ua) && ua.includes('MQQBrowser/') && ( ver = /MQQBrowser\/\d*/.exec(ua)[0].replace('MQQBrowser/',''), ver >= 5 )),
'此 UA 可能会导致 蓝奏云部分页面 加载广告时弹出 确认/取消 对话框'
],[ // #6 淘宝 windvine 确认框
( ua.includes('Android') && /WindVane\/\d+\.\d+\.\d+/.test(ua) && ( ver = /WindVane\/\d+/.exec(ua)[0].replace('WindVane/',''), ver >= 1 )),
'此 UA 可能会导致 淘宝部分页面 加载时弹出 确认/取消 对话框'
]
];
let count = 0;
issue.forEach( i => {
if (i[0]) { count++; };
});
cleanIssue();
if (count>0) { makeIssue(`检测到 ${count} 个问题 :`,true); };
issue.forEach( i => {
if (i[0]) { makeIssue(i[1],false); };
});
}
function makeFlagDiv(clas,box,chinese,opa) {
const flag = document.createElement("div");
flag.className = "flag";
flag.innerHTML = tagConv(clas,chinese,true);
clas = tagConv(clas,chinese,false);
if (!box) { _(flag,false,`T${clas}`); }
flag.style.cssText = `background-color:${uaData.flag[clas][1]};color:${uaData.flag[clas][2]};opacity:${opa}`;
return flag;
}
function makeHeadandLink(first) {
const head = document.createElement("div");
Object.assign(head,{
id: `i${first}`,
innerHTML: first,
className: "CaseHead"
});
if(!uaData.touch) {
const jump = document.createElement("a");
Object.assign(jump,{
href: `#i${first}`,
innerHTML: first
});
$(false,"#ajump").appendChild(jump);
} else {
uaData.index += first;
}
return head;
}
function pushTagText(cls,app) {
if (uaData.tagtext[cls]===undefined) { uaData.tagtext[cls] = []; }
uaData.tagtext[cls].push(app);
}
function parseClassinItem(lab,app) {
let count = 0;
if (uaData.apps[app].class.length===0) {
pushTagText("no_tag",app);
lab.className = "no_tag";
return 1;
} else {
uaData.apps[app].class.forEach( cls => {
if (cls.slice(0,1)==="_" || uaData.tagfind[cls]!==undefined) {
count += 1;
lab.appendChild(makeFlagDiv(cls,false,true,1));
if (cls.slice(0,1)==="_") {
cls = "third";
} else {
cls = uaData.tagfind[cls];
}
pushTagText(cls,app);
_(lab,false,cls);
} else {
toast(`项目 "${app}" 被指定了不存在的标签 "${cls}" ...`);
uaData.stor.apps[app].class.splice(
uaData.stor.apps[app].class.findIndex( v => {
return v === cls;
}),1
);
loc.setItem(uaData.storKey,JSON.stringify(uaData.stor));
location.reload();
}
});
return count;
}
}
function newBox(type) {
const box = document.createElement("span");
box.className = `new-style new-${type}`;
return box;
}
function makeItem() {
let ofirst = "Z",cont = $(false,"#app_container");
Object.keys(uaData.apps).sort().forEach( app => {
uaData.text[app] = uaData.apps[app].text;
const lab = document.createElement("label"),
box = document.createElement("input"),
first = getUpperHead(app);
if (first!==ofirst) {
cont.appendChild(makeHeadandLink(first));
ofirst = first;
}
lab.id = app;
lab.tabIndex = 0;
lab.addEventListener('keydown', (e) => { uaCode.util.check(e); });
lab.innerHTML += uaData.apps[app].text;
uaData.count[app] = parseClassinItem(lab,app);
if (uaData.设置.测试模式) {
const idi = document.createElement("i");
let id = app;
if (uaData.apps[app].followed) { id = uaData.设置.无缝记号 + id; }
if (uaData.apps[app].prefix) { id = uaData.设置.前置记号 + id; }
idi.innerHTML = id;
lab.appendChild(idi);
}
Object.assign(box, {
type: "checkbox",
name: "app",
value: app,
className: "orig-box",
tabIndex: -1
});
lab.appendChild(box);
lab.appendChild(newBox("check"));
cont.appendChild(lab);
});
cont.addEventListener('keydown',(e) => {
if (e.code==="Space") {
e.preventDefault();
}
});
if (uaData.touch) {
uaData.indexSidebar1 = new IndexSidebar({
mounted: document.querySelector('#app')
});
} else {
_($(false,'#ajump'),true,'none');
};
}
function makeFlaginBox() {
Object.keys(uaData.flag).forEach( flag => {
const lab = document.createElement("label"),
box = document.createElement("input");
lab.id = `L${flag}`;
lab.tabIndex = 0;
lab.addEventListener('keydown', (e) => { uaCode.util.check(e); });
Object.assign(box, {
type: "checkbox",
name: "flag",
id: `B${flag}`,
value: flag,
checked: true
});
box.addEventListener('change', e => {
uaCode.tagClick(e.target.parentNode.id,true);
});
lab.appendChild(box);
lab.appendChild(makeFlagDiv(flag,true,false,1));
$(false,"#classBox").appendChild(lab);
});
}
function makeBaseRadio() {
Object.keys(uaData.base).forEach( base => {
const lab = document.createElement("label"),
box = document.createElement("input");
lab.for = base;
lab.tabIndex = 0;
lab.addEventListener('keydown', (e) => { uaCode.util.check(e); });
Object.assign(box, {
type: "radio",
name: "base",
id: base,
value: base,
className: "orig-box",
tabIndex: -1
});
lab.appendChild(box);
lab.appendChild(newBox("radio"));
lab.innerHTML += uaData.base[base].text;
$(false,"#baseopt").appendChild(lab);
if ($(true,"#baseopt label").length===uaData.设置.基础默认) {
$(false,`#${base}`).checked = true;
}
});
}
function winActiv(awin) {
let wing = $(true,".win");
wing.forEach( (win,i) => {
if (win.style.zIndex>awin.style.zIndex) {
win.style.zIndex--;
}
});
awin.style.zIndex = wing.length + 1;
}
function dndWin() {
let wing = $(true,".win");
wing.forEach( (win,i) => {
win.style.zIndex = i + 2;
});
if (uaData.touch) {
wing.forEach( win => {
win.addEventListener('touchstart', e => {
if (e.target.nodeName!=="TEXTAREA"&&!$(false,'#issues').contains(e.target)) {
pos = [
(e.touches[0].clientX - win.offsetLeft),
(e.touches[0].clientY - win.offsetTop)
];
}
winActiv(win);
},{ passive: true });
win.addEventListener('touchmove', e => {
if (e.target.nodeName!=="TEXTAREA"&&!$(false,'#issues').contains(e.target)) {
win.style.left = (e.touches[0].clientX - pos[0]) + 'px';
win.style.top = (e.touches[0].clientY - pos[1]) + 'px';
}
win.style.position = (parseInt(getComputedStyle(win)['right']) < 0 ||
parseInt(getComputedStyle(win)['left']) < 0 ||
parseInt(getComputedStyle(win)['bottom']) < 0) ?
'fixed' : 'absolute' ;
},{ passive: true });
});
} else {
$(true,".drag").forEach( drag => {
let win = drag.parentNode.parentNode;
drag.addEventListener('mousedown', e => {
pos = [
(e.clientX - win.offsetLeft),
(e.clientY - win.offsetTop)
];
winActiv(win);
document.onmousemove = e => {
win.style.left = (e.clientX - pos[0]) + 'px';
win.style.top = (e.clientY - pos[1]) + 'px';
};
document.removeEventListener('mouseup', uaCode.util.unlock);
document.addEventListener('mouseup', uaCode.util.unlock);
});
});
wing.forEach( win => {
win.addEventListener('mousedown', e => {
winActiv(win);
});
});
}
}
function openWin(win) {
_(win,true,"none");
winActiv(win);
}
function filterExec(item,nclass) {
let found = 0;
lab.forEach( ele => {
found = 0;
item.forEach( val => { found += val===ele.id ? 1 : 0; });
_(ele,found>=1,nclass);
});
scanForHead();
_(ntx,scanAll()===0,"none");
}
function filterResume(nclass) {
lah.forEach( ele => { _(ele,true,nclass); });
scanForHead();
if (scanAll()!==0) { _(ntx,false,"none"); }
}
function fltAppUA(word) {
if (word==="") {
filterResume("none");
} else {
const item = Object.keys(uaData.text).filter(obj => uaData.text[obj].toLowerCase().includes(word.toLowerCase()));
filterExec(item,"none");
}
}
function fltAppUASelected(btn) {
if (btn.innerHTML==="列出已选") {
const item = [];
$_("app").forEach( ele => item.push(ele.value));
filterExec(item,"sel_none");
btn.innerHTML = "列出全部";
} else {
filterResume("sel_none");
btn.innerHTML = "列出已选";
}
}
function fltAppUATag(clas,selected) {
$(true,`.T${clas}`).forEach( tag => {
if (selected) {
_(tag,true,"none");
} else {
_(tag,false,"none");
}
});
if (uaData.tagtext[clas]!==undefined) {
uaData.tagtext[clas].forEach( id => {
if (selected) {
uaData.count[id]++;
} else {
uaData.count[id]--;
}
});
}
const item = Object.keys(uaData.count).filter(obj => uaData.count[obj]!==0);
filterExec(item,"tag_none");
}
function tagClick(id,flt) {
const box = $(false,`#${id} input`);
flag = $(false,`#${id} .flag`);
flag.style.opacity = (box.checked) ? 1 : .5;
if (flt) {
fltAppUATag(id.slice(1),box.checked);
$(false,'#openClass').style.backgroundColor = ($(true,'#classBox input:not(:checked)').length===0) ? '' : uaData.设置.标签筛选开启;
}
}
/* "添加" 窗口表单 相关 */
function aform_tType(type) {
switch (type) {
case "aapp":
return "a";
break;
case "qapp":
return "q";
break;
case "atag":
return "t";
break;
}
}
function aform_switchModify() {
const type = aform_tType($_("atype").value),
sel = $(false,`#${type}sell`),
key = $(false,`#${type}keyl`),
btn = $(false,'#anew'),
ok = $(false,'#aok');
if (btn.innerHTML==="管理") {
_(key,false,"none");
_(sel,true,"none");
btn.innerHTML = "添加";
ok.innerHTML = "确定";
} else {
_(key,true,"none");
_(sel,false,"none");
btn.innerHTML = "管理";
ok.innerHTML = "加入";
}
}
function aform_switchCard() {
const val = $_("atype").value;
$(true,".atab").forEach( tab => {
if (tab.id===`${val}t`) {
_(tab,true,"none");
$(false,'#anew').innerHTML = "添加";
aform_switchModify();
} else {
_(tab,false,"none");
}
});
}
function aform_switchBoth() {
const val = $_("apre").value,
both = $(true,".acont2"),
sing = $(false,".acont1");
if (val==="both") {
both.forEach( input => { _(input,true,"none"); });
_(sing,false,"none");
} else {
both.forEach( input => { _(input,false,"none"); });
_(sing,true,"none");
}
}
function aform_makeFlaginBox() {
$(true,".classBox").forEach( sbox => {
Object.keys(uaData.flag).forEach( flag => {
if (flag!=="qapp" && flag!=="no_tag") {
const lab = document.createElement("label"),
box = document.createElement("input");
lab.id = `${getUpperHead(sbox.id)}${flag}`;
lab.tabIndex = 0;
lab.addEventListener('keydown', (e) => { uaCode.util.check(e); });
Object.assign(box, {
type: "checkbox",
name: "sflag",
id: `${sbox.id.slice(0,1)}${flag}`,
value: flag,
checked: false
});
if (flag==="third") {
box.addEventListener('change', e => {
uaCode.tagClick(e.target.parentNode.id,false);
if (box.checked) {
_($(false,`#${sbox.id}l`),true,"none");
} else {
_($(false,`#${sbox.id}l`),false,"none");
}
});
} else {
box.addEventListener('change', e => {
uaCode.tagClick(e.target.parentNode.id,false);
});
}
lab.appendChild(box);
lab.appendChild(makeFlagDiv(flag,true,false,0.5));
sbox.appendChild(lab);
}
});
});
}
function aform_updateFlagPreview() {
const box = $(false,'#tclsbox'),
txt = $(false,'#ttext').value,
bgc = $(false,'#tbgc').value,
fgc = $(false,'#tfgc').value;
if (txt!=="") {
box.innerHTML = txt;
_(box,true,"none");
} else {
_(box,false,"none");
}
box.style.cssText = `background-color:${bgc};color:${fgc}`;
}
function aform_Clear() {
$(true,'#addtable input[type="text"]').forEach( i => {
i.value = "";
i.style.borderColor = uaData.设置.输入框检查[0];
});
$(false,'#tkds').style.borderColor = uaData.设置.输入框检查[0];
$(true,".classBox input").forEach( c => { c.checked = false; });
$(true,".classBox .flag").forEach( f => { f.style.opacity = .5; });
$(true,".classPart label").forEach( t => { _(t,false,"none"); });
$(true,'#apref,#afolf').forEach( r => { r.checked = true; });
$(true,'.msel').forEach( s => { s.value = ""; });
$(false,'#tbgc').value = '#000000';
$(false,'#tfgc').value = '#ffffff';
aform_updateFlagPreview();
aform_switchBoth();
}
function aform_Check(type) {
let a = true;
$(true,`#${type}t input[type="text"]`).forEach( i => {
i.style.borderColor = uaData.设置.输入框检查[0];
if (getComputedStyle(i).display!=="none" &&
getComputedStyle(i.parentNode).display!=="none" &&
i.value==="") {
if (i.id==="tkey") {
$(false,'#tkds').style.borderColor = uaData.设置.输入框检查[3];
} else {
i.style.borderColor = uaData.设置.输入框检查[3];
}
a = false;
}
});
return (a && $(false,'#anew').innerHTML==="管理") ? aform_KeyCheck(true) : a ;
}
function aform_KeyCheck(toast) {
const type = aform_tType($_('atype').value), test = /^\w+$/u;
let inp = $(false,`#${type}key`), key = inp.value,
bor = (type==="t") ? $(false,'#tkds') : inp;
if (!test.test(key)) {
bor.style.borderColor = uaData.设置.输入框检查[2];
if(toast){ uaCode.util.toast('输入错误'); }
return false;
}
switch (type) {
case "t":
if (key in uaData.flag||key in uaData.stor.flag) {
bor.style.borderColor = uaData.设置.输入框检查[2];
if(toast){ uaCode.util.toast('标识重复'); }
return false;
} else if (key.slice(0,1)==="_") {
bor.style.borderColor = uaData.设置.输入框检查[2];
if(toast){ uaCode.util.toast('"_" 开头用于自定义标签'); }
return false;
}
break;
default:
if (key in uaData.apps||key in uaData.stor.apps) {
bor.style.borderColor = uaData.设置.输入框检查[2];
if(toast){ uaCode.util.toast('标识重复'); }
return false;
}
break;
}
if (key==="") {
bor.style.borderColor = uaData.设置.输入框检查[0];
return false;
} else {
bor.style.borderColor = uaData.设置.输入框检查[1];
return true;
}
}
function aform_Add() {
const atyp = $_("atype").value;
let key,name,pre,nfol,cont,obj,flag,typr,opt;
function convBool(val) { return (val==="true") ? true : false ; }
if (!aform_Check(atyp)) { return; }
typr = aform_tType(atyp);
key = ($(false,'#anew').innerHTML==="管理") ?
$(false,`#${typr}key`).value :
$(false,`#${typr}sel`).value ;
if (key==="" && $(false,'#anew').innerHTML==="添加") {
toast("请选择需要修改的项目");
return;
}
switch (typr) {
case "a":
cont = ($_("apre").value!=="both") ?
$(false,"#acont1").value : [
$(false,"#acont2a").value,
$(false,"#acont2b").value ];
break;
case "q":
cont = {
qBasic: $(false,"#qcont1").value,
qFrom: $(false,"#qcont2").value,
qString: $(false,"#qcont3").value,
};
break;
}
if (atyp==="atag") {
obj = [
$(false,'#ttext').value,
$(false,'#tbgc').value,
$(false,'#tfgc').value
]
Object.assign(uaData.stor.flag, { [`${key}`]: obj });
} else {
obj = {
text: $(false,`#${typr}text`).value,
prefix: (atyp==="qapp"||$_("apre").value==="both") ? false :
convBool($_("apre").value),
followed: (atyp==="qapp") ? false : convBool($_("afol").value),
content: (atyp==="qapp") ? {
平台:cont.qBasic,
来自:cont.qFrom,
应用:cont.qString
} : cont,
class: (atyp!=="qapp") ? [] : ["快应用"]
}
$_("sflag").forEach( inp => {
if(inp.id.slice(1)==="third") {
obj.class.push("_" + $(false,`#${typr}thirdt`).value);
} else {
obj.class.push(tagConv(inp.id.slice(1),false,true));
}
});
Object.assign(uaData.stor.apps, {
[`${key}`]: {
名称: obj.text,
前置: (obj.prefix) ? "" : "不是",
无缝: (obj.followed) ? "" : "不是",
标签: obj.class,
内容: obj.content
}
});
}
if ($(false,'#anew').innerHTML==="管理") {
opt = document.createElement('option');
if (atyp==="atag") {
opt.value = key; opt.innerHTML = `${obj[0]} (${key})`;
} else {
opt.value = key; opt.innerHTML = `${obj.text} (${key})`;
}
$(false,`#${typr}sel`).appendChild(opt);
aform_Clear();
} else {
opt = $(false,`#${typr}sel option[value="${key}"]`);
if (atyp==="atag") {
opt.innerHTML = `${obj[0]} (${key})`;
} else {
opt.innerHTML = `${obj.text} (${key})`;
}
aform_Clear();
}
$(false,'#ssave').style.backgroundColor = uaData.设置.数据未保存;
if ($(false,'#aok').innerHTML==="加入") {
toast('加入成功');
} else {
toast('修改成功');
}
}
function aform_Modify() {
const type = aform_tType($_("atype").value),
item = $(false,`#${type}sel`).value;
let obj,cobj,cont,ccls = [];
switch (type) {
case "t" :
obj = uaData.stor.flag[item];
break;
default:
cobj = uaData.stor.apps[item];
if (typeof cobj["内容"] === "object") {
if (cobj["内容"] instanceof Array) {
cont = [cobj["内容"][0],cobj["内容"][1]];
} else {
cont = {
qBasic: cobj["内容"]["平台"],
qFrom: cobj["内容"]["来自"],
qString: cobj["内容"]["应用"]
}
}
} else {
cont = cobj["内容"];
}
cobj["标签"].forEach( ct => {
ccls.push((ct.slice(0,1)==="_") ? ct : uaData.tagfind[ct]);
});
obj = {
text: cobj["名称"],
prefix: (cobj["前置"]==="") ? true : false,
followed: (cobj["无缝"]==="") ? true : false,
class: ccls,
content: cont
}
break;
}
function resetClass(type) {
$(true,`#${type}clsbox input`).forEach( c => { c.checked = false; });
$(true,`#${type}clsbox .flag`).forEach( f => { f.style.opacity = .5; });
_($(false,`#${type}clsboxl`),false,"none");
}
function tagSelect(id) {
const box = $(false,`#${id} input`);
flag = $(false,`#${id} .flag`);
box.checked = true;
flag.style.opacity = 1;
}
switch (type) {
case "a" :
$(false,"#atext").value = obj.text;
if (obj.content instanceof Array) {
$(false,"#apreb").checked = true;
aform_switchBoth();
$(false,"#acont2a").value = obj.content[0];
$(false,"#acont2b").value = obj.content[1];
} else {
if (obj.prefix) {
$(false,"#apret").checked = true;
} else {
$(false,"#apref").checked = true;
}
aform_switchBoth();
$(false,"#acont1").value = obj.content;
}
if (obj.followed) {
$(false,"#afolt").checked = true;
} else {
$(false,"#afolf").checked = true;
}
resetClass(type);
obj.class.forEach( cls => {
if (cls.slice(0,1)==="_") {
tagSelect("Athird");
_($(false,"#aclsboxl"),true,"none");
$(false,"#athirdt").value = cls.slice(1);
} else {
tagSelect(`A${cls}`);
}
});
break;
case "q" :
$(false,"#qtext").value = obj.text;
$(false,"#qcont1").value = obj.content.qBasic;
$(false,"#qcont2").value = obj.content.qFrom;
$(false,"#qcont3").value = obj.content.qString;
resetClass(type);
obj.class.forEach( cls => {
if (cls!=="qapp") {
if (cls.slice(0,1)==="_") {
tagSelect("Qthird");
_($(false,"#qclsboxl"),true,"none");
$(false,"#qthirdt").value = cls.slice(1);
} else {
tagSelect(`Q${cls}`);
}
}
});
break;
case "t" :
$(false,"#ttext").value = obj[0];
$(false,"#tbgc").value = obj[1];
$(false,"#tfgc").value = obj[2];
aform_updateFlagPreview();
break;
}
}
function aform_Delete() {
const type = aform_tType($_("atype").value),
sel = $(false,`#${type}sel`),
val = sel.value,
opt = $(false,`#${type}sel option[value="${val}"]`);
if ($(false,'#anew').innerHTML==="添加") {
if (val!=="") {
switch (type) {
case "t" :
delete uaData.stor.flag[val];
break;
default:
delete uaData.stor.apps[val];
break;
}
sel.removeChild(opt);
aform_Clear();
$(false,'#ssave').style.backgroundColor = uaData.设置.数据未保存;
toast('删除成功');
} else {
toast('没有选择项目');
}
} else {
toast('只能在管理模式下删除项目');
}
}
/* localStorage 相关 */
function lsb_initOption() {
if (Object.keys(uaData.stor).length!==0) {
if (uaData.stor.apps) {
Object.keys(uaData.stor.apps).forEach( app => {
let sel, opt = document.createElement('option');
sel = (uaData.stor.apps[app].内容.来自) ?
$(false,'#qsel') : $(false,'#asel');
opt.value = app; opt.innerHTML = `${uaData.stor.apps[app].内容} (${app})`;
sel.appendChild(opt);
});
}
if (uaData.stor.flag) {
Object.keys(uaData.stor.flag).forEach( tag => {
let sel = $(false,'#tsel'), opt = document.createElement('option');
opt.value = tag; opt.innerHTML = `${uaData.stor.flag[tag][0]} (${tag})`;
sel.appendChild(opt);
});
}
}
}
function lsb_save() {
if (Object.keys(uaData.stor.apps).length!==0 ||
Object.keys(uaData.stor.flag).length!==0) {
loc.setItem(uaData.storKey,JSON.stringify(uaData.stor));
$(false,'#ssave').style.backgroundColor = '';
toast('保存成功,下次刷新生效');
} else {
toast('没有自定义数据');
}
}
function lsb_export() {
if (loc.hasOwnProperty(uaData.storKey)) {
$(false,"#stordata").value = loc.getItem(uaData.storKey);
} else {
toast('没有自定义数据');
}
}
function lsb_import() {
let err = 0;
if ($(false,"#stordata").value!=="") {
try {
const data = JSON.parse($(false,"#stordata").value);
if (loc.hasOwnProperty(uaData.storKey)) {
let odata = JSON.parse(loc.getItem(uaData.storKey));
Object.keys(data).forEach( k => {
if (odata[k]) {
Object.assign(odata[k],data[k]);
} else {
odata[k] = data[k];
}
});
loc.setItem(uaData.storKey,JSON.stringify(odata));
} else {
loc.setItem(uaData.storKey,JSON.stringify(data));
}
$(false,"#stordata").value = "";
} catch(e) {
err = 1;
if (e instanceof SyntaxError) {
toast('导入失败:格式不正确');
} else {
toast('导入失败');
}
}
if (err===0) { toast('导入成功'); }
} else {
toast('没有输入数据');
}
}
function lsb_clear() {
loc.removeItem(uaData.storKey);
toast('清空啦');
}
function init(){
$(false,'#loadstr').innerHTML = '正在构建 ...';
lsb_initOption();
makeItem();
makeFlaginBox();
aform_makeFlaginBox();
makeBaseRadio();
dndWin();
$(false,'#loadstr').innerHTML = '正在初始化 ...';
$(false,"#Raapp").checked = true;
$(false,"#stordata").value = '';
aform_Clear();
$(false,"#search").value = '';
$(false,"#version").innerHTML = `版本:${uaData.设置.代码版本} 总数:${Object.keys(uaData.apps).length}`;
$(false,'#loadstr').innerHTML = '加载完成';
_($(false,"#load"),false,"finish");
lab = $(true,"#app_container label"),
cas = $(true,"#app_container .CaseHead"),
lah = $(true,"#app_container > label,.CaseHead"),
ntx = $(false,"#nulltext");
loc = window.localStorage;
};
return {
init: init,
gen: genUA,
tagClick: tagClick,
open: openWin,
check: issuesCheck,
filter: {
app: fltAppUA,
sel: fltAppUASelected,
},
util: {
_: _,
$: $,
$_: $_,
unlock: function() {
document.onmousemove = null;
},
check: spaceChecked,
toast: toast,
},
aform: {
switchBoth: aform_switchBoth,
switchCard: aform_switchCard,
updateFlagPreview: aform_updateFlagPreview,
add: aform_Add,
clear: aform_Clear,
del: aform_Delete,
check: aform_KeyCheck,
switchModify: aform_switchModify,
modify: aform_Modify,
},
lsb: {
save: lsb_save,
clear: lsb_clear,
import: lsb_import,
export: lsb_export,
}
}
})();
</script>
<script>
window.onerror = function(e,a,l) {
alert(`错误: ${e}\n地址: ${a}\n行数: ${l}`);
}
function 加入(box,obj) {
switch (box) {
case "标签":
Object.assign(uaData.flag,obj);
Object.keys(obj).forEach( key => {
uaData.tagfind[obj[key][0]] = key;
});
break;
case "APP":
Object.keys(obj).forEach( key => {
let cont;
if (typeof obj[key]["内容"] === "object") {
if (obj[key]["内容"] instanceof Array) {
cont = [obj[key]["内容"][0],obj[key]["内容"][1]];
} else {
cont = {
qBasic: obj[key]["内容"]["平台"],
qFrom: obj[key]["内容"]["来自"],
qString: obj[key]["内容"]["应用"]
}
}
} else {
cont = obj[key]["内容"];
}
Object.assign(uaData.apps,{
[key]: {
text: obj[key]["名称"],
prefix: (obj[key]["前置"]==="") ? true : false,
followed: (obj[key]["无缝"]==="") ? true : false,
class: obj[key]["标签"],
content: cont
}
});
});
break;
case "基础":
Object.keys(obj).forEach( key => {
if (key!=="默认项") {
Object.assign(uaData.base,{
[key]: {
text: obj[key]["名称"],
content: obj[key]["内容"]
}
});
}
});
break;
case "数据":
obj.forEach( js => { uaData.jslist.push(js); });
break;
}
}
</script>
<script src="数据列表.js"></script>
<script>
uaData.jslist.forEach( js => {
let script=document.createElement('script');
script.async = false;
script.src = js;
script.onerror = e => {
uaCode.util.toast(js + " 加载失败");
window.stop();
}
document.querySelector("head").appendChild(script);
});
</script>
<script>
(() => {
const stor = window.localStorage;
uaCode.util.$(false,'#loadstr').innerHTML = '正在加载数据 ...';
if (stor.hasOwnProperty(uaData.storKey)) {
try {
let data = JSON.parse(stor.getItem(uaData.storKey));
if (data.apps) {
Object.assign(uaData.stor.apps,data.apps);
加入("APP",data.apps);
}
if (data.flag) {
Object.assign(uaData.stor.flag,data.flag);
加入("标签",data.flag);
}
} catch(e) {
alert(`存储数据异常,将会被清空...\n 内容:${stor.getItem(uaData.storKey)}`);
stor.removeItem(uaData.storKey);
}
}
})();
</script>
<script>
window.onload = uaCode.init;
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化