// ==UserScript==
// @name 星凰·众里寻她千百度
// @version 5.20
// @author 科技星凰
// @namespace https://space.bilibili.com/379335206
// @match https://www.baidu.com/
// @match https://www.baidu.com/?bs_nt=1
// @match https://www.baidu.com/?tn=*
// @description 我们有幸降落在这个星球...这是他们一生也无法看到的风景...
// @require https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js
// @supportURL https://jq.qq.com/?_wv=1027&k=IMqY916N
// @icon https://cdn.jsdelivr.net/gh/loktindyi/mybaiduhp@master/tri-bdhp-icon.png
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_xmlhttpRequest
// @note 5.20 这个版本准备了很久 修改过很多次 功能终于接近完善 因此直接跳到这个版本号
// @downloadURL none
// ==/UserScript==
(() => {
console.time("星凰·众里寻她千百度\n\t本次耗时");
const addCss = GM_addStyle,
setValue = GM_setValue,
getValue = GM_getValue,
delValue = GM_deleteValue,
trequest = GM_xmlhttpRequest;
const NOTICE_TRISAY_KEEPER = 6; //NOTICE时长
const TRI_UPDATE_NOTICE =
`欢迎使用《星凰·众里寻她千百度》
右边缘双击可打开配置
`;
const IMAGES = [
"http://g.hiphotos.baidu.com/zhidao/pic/item/8644ebf81a4c510f973523a36b59252dd52aa592.jpg",
"https://cdn.jsdelivr.net/gh/loktindyi/mybaiduhp@master/imgraw.png",
"https://cdn.jsdelivr.net/gh/loktindyi/mybaiduhp@master/tri-bdhp-icon.png"
];
const LOGO_LIST = [
"", //春 未至
"https://i0.hdslb.com/bfs/archive/e62b6b095ef38dfb742687f11e4b570dde420b5d.png",
"https://i0.hdslb.com/bfs/archive/622017dd4b0140432962d3ce0c6db99d77d2e937.png",
"https://i0.hdslb.com/bfs/vc/fb9521333b8ea79d90bdfc6da31cf83c52d93ec9.png"
];
const API = [
"https://api.bilibili.com/x/web-show/res/locs?pf=0&ids=142",
"https://www.bing.com/HPImageArchive.aspx?format=js&n=1"
];
const DEFAULT_CONFIG = {
searchInputOpt: false, //搜索框
luma: false, //流光
vzin: false, //维新
pageTiltle: "众里寻她千百度", //标题
topLeft: false, //左上角推广
userList: false, //右上角用户
hotNews: false, //新闻
inputLenTillTop: [90, 280], //搜索框位置
inputFontSize: 20, //字体大小
pageBackgroundImg: IMAGES[0],//背景图片地址
pageBackgroundImgBing: false, //必应背景图
replaceLogo: 233, //logo
cusLogoUrl: "", //自定义logourl
tipDeLogo: "前往哔哩哔哩", //logo提示语
targetDeLogo: false, //跳转方式
logoLinksTo: "https://www.bilibili.com", //链接到
thmColor: ["#222c", "rgb(250 114 152 / 1)", "#0000", "rgb(250 114 152 / .8)"], //fc fo bg bd
triSay: TRI_UPDATE_NOTICE //triSay
};
const TRI_HTML = [
`
`,
``
];
const TRI_CSS_TEXT = {
searci: `html {overflow: hidden}#s_wrap {display: none}#head_wrapper .s_btn {opacity: 0}#head_wrapper .ipt_rec,#head_wrapper .soutu-btn {display: none}#head_wrapper #kw,#head_wrapper #kw:focus {background-color: var(--thm-bg);color: var(--thm-fc);border-color: var(--thm-bd) !important}#head_wrapper #form .bdsug-new {position: absolute;left: 6%;top: 55px !important;background-color: #fff;border-radius: 10px;box-shadow: 0 0 15px 3px rgba(250, 114, 152, .3);border: none !important;position: absolute;top: 55px}.bdsug-s,.bdsug-s b {color: var(--thm-fo) !important;font-size: large !important}#head_wrapper #form .bdsug-new ul {border-top: none;}#head_wrapper .soutu-env-nomac #form #kw,#head_wrapper #form #kw {width: 618px !important;padding-right: 16px !important;border-style: solid;border-radius: 10px;text-align: center}`,
others: `#bottom_layer {display: none}#s_side_wrapper {display: none}#head_wrapper #kw {font-size: calc(var(--ipt-fz) * 1px)}#head .head_wrapper {top: calc(var(--ipt-len) * 1px)}.s-hotsearch-wrapper {display: none}#s_top_wrap {display: none}body {background-size: cover;background-attachment: fixed}#headwrapper #form .bdsug-new user_list {border-top-color: transparent}`,
tris: `@keyframes twinkling {0% {opacity: 0}20% {opacity: 1}40% {opacity: 0}60% {opacity: 1}80% {opacity: 0}100% {opacity: 1}}@keyframes appear {from {visibility: hidden;opacity: 0}to {visibility: visible;opacity: 1}}@keyframes fullfadeout {from {visibility: visible;opacity: 1}to {visibility: hidden;opacity: 0}}@keyframes fadeout {from {opacity: 0.85}to {opacity: 0}}@keyframes tminus {from {width: 0}to {width: 320px}}.trisay {box-shadow: 0 0 15px 3px rgba(250, 114, 152, .3);user-select: none;overflow: hidden;min-width: 60px;background: #fff;opacity: 0.85;width: 320px;height: auto;font-size: 14px;min-height: 30px;color: var(--thm-fo);line-height: 30px;text-align: center;border-radius: 5px;position: fixed;top: 60%;left: 40%;z-index: 998}.v-hr {height: 1px;border: none;background-color: var(--thm-fo);z-index: 997}.trisay-hr {height: 5px;border: none;background-color: var(--thm-fo);animation: tminus var(--hr-time) linear forwards;z-index: 999}.fadeout {animation: fadeout 0.5s forwards}.ts {display: none;opacity: 0}.in {animation: appear 0.8s forwards}.out {animation: fullfadeout 0.8s forwards}.fs-ipt {padding-left: 5px;background: #fff8;border: solid 1px var(--thm-bd);border-radius: 5px;outline: none;height: 18px;font-size: 60%;z-index: 997}#vlogo {height: 16px;font-size: 12px;outline: none}.cus-lg {position: absolute;right: 15%;top: 38%;width: 30%}.ipnum {width: 12%}.btn {outline: none;border: none;position: absolute;}.b-a {border-radius: 8px;color: var(--thm-fo);background-color: rgba(255, 255, 255, 0.6);box-shadow: 0 0 15px 3px rgba(250, 114, 152, .4);}.tri-dis {top: 0;right: -2px;width: 7px;height: 100%;background-color: transparent;background-image: linear-gradient(to left, var(--thm-fo), transparent);opacity: 0}.tri-dis:hover {animation: appear 0.1s linear forwards}.joinus {top: 2%;right: 4%;width: 80px;height: 40px;animation: twinkling 2s 1 ease-in-out forwards;z-index: 998}.save-btn {font-size: large;bottom: 25%;right: 6%;width: 100px;height: 50px}.fdt {color: var(--thm-fo);font-size: 23px;position: absolute;top: 3%;left: 3%;}#tri-fds {position: fixed;top: 7%;right: 5%;border-radius: 15px;border-color: #0000;padding: 15px;font-size: 14px;line-height: 200%;height: 600px;color: #222;width: 300px;background-color: rgba(255, 255, 255, 0.8);background-image: var(--wallpaper);text-align: left;user-select: none;z-index: 996}#tri-fds:hover {box-shadow: 0 0 15px 3px rgba(250, 114, 152, .3);}.trilato {border-radius: 10px;padding: 5px;background-color: #fff8;position: absolute;width: 90%;height: 10%;cursor: pointer;font-size: large;color: var(--thm-fo)}.trilato span {position: absolute;right: 10px}.trimg {position: absolute;bottom: 8px;left: 10px;width: 32px}`,
luma: `.trifm {margin: auto;top: calc(var(--ipt-len) * 1px)}#tript {border-bottom: solid 2px var(--thm-bd);outline: none;color: var(--thm-fc);background-color: var(--thm-bg);margin: auto;height: 40px;width: 540px;font-size: calc(var(--ipt-fz) * 1px);text-align: center;}`
};
function triSay(msg, duration) {
duration = isNaN(duration) ? 3 : duration;
addCss(`:root{--hr-time: ` + duration + `s}`);
let m = document.createElement('div');
let n = document.createElement('hr');
m.className = "trisay";
n.className = "trisay-hr";
m.innerHTML = msg.replace(/\n/g, '
');
document.body.appendChild(m);
m.appendChild(n);
setTimeout(() => {
m.className += " fadeout";
setTimeout(() => {
document.body.removeChild(m)
}, 1000);
}, duration * 1000);
}
function trilog(say) {
console.log('%c TriLingvo %c\n' + say, 'color:#fff;background-color:#fa7298;border-radius:8px', '');
}
function savl(settings) {
let els = {
search: $('#vsearch')[0],
luma: $('#luma')[0],
vzin: $('#vzin')[0],
pagetitle: $('#pagetitle')[0],
topleft: $('#topleft')[0],
user: $('#vuser')[0],
news: $('#vnews')[0],
ipos: $('#ipos')[0],
ipfz: $('#ipfz')[0],
bgimg: $('#bgimg')[0],
bgimgbing: $('#bgimg-bing')[0],
logo: $('#vlogo')[0],
cuslgurl: $('#cuslgurl')[0],
lgtip: $('#lgtip')[0],
lgtar: $('#lgtar')[0],
lglinksto: $('#lglinksto')[0],
thmcolor0: $('#thmcolor0')[0],
thmcolor1: $('#thmcolor1')[0],
thmcolor2: $('#thmcolor2')[0],
thmcolor3: $('#thmcolor3')[0]
//Ne triSay
}
if (!settings) {
return {
searchInputOpt: els.search.checked,
luma: els.luma.checked,
vzin: els.vzin.checked,
pageTiltle: els.pagetitle.value,
topLeft: els.topleft.checked,
userList: els.user.checked,
hotNews: els.news.checked,
inputLenTillTop: UserConfig.luma ? [UserConfig.inputLenTillTop[0], els.ipos.value] : [els.ipos.value, UserConfig.inputLenTillTop[1]],
inputFontSize: els.ipfz.value,
pageBackgroundImg: els.bgimg.value,
pageBackgroundImgBing: els.bgimgbing.checked,
replaceLogo: parseInt(els.logo.value),
cusLogoUrl: els.cuslgurl.value,
tipDeLogo: els.lgtip.value,
targetDeLogo: els.lgtar.checked,
logoLinksTo: els.lglinksto.value,
thmColor: [els.thmcolor0.value, els.thmcolor1.value, els.thmcolor2.value, els.thmcolor3.value]
}
} else {
els.search.checked = settings.searchInputOpt;
els.luma.checked = settings.luma;
els.vzin.checked = settings.vzin;
if (settings.pageTiltle) els.pagetitle.value = settings.pageTiltle;
els.topleft.checked = settings.topLeft;
els.user.checked = settings.userList;
els.news.checked = settings.hotNews;
els.ipos.value = settings.luma ? settings.inputLenTillTop[1] : settings.inputLenTillTop[0];
els.ipfz.value = settings.inputFontSize;
els.bgimg.value = settings.pageBackgroundImg;
els.bgimgbing.checked = settings.pageBackgroundImgBing;
els.logo.value = settings.replaceLogo;
els.cuslgurl.value = settings.cusLogoUrl;
els.lgtip.value = settings.tipDeLogo;
settings.targetDeLogo ? els.lgtar.checked = true : $('#lgtars')[0].checked = true;
els.lglinksto.value = settings.logoLinksTo;
els.thmcolor0.value = settings.thmColor[0];
els.thmcolor1.value = settings.thmColor[1];
els.thmcolor2.value = settings.thmColor[2];
els.thmcolor3.value = settings.thmColor[3];
if (settings.replaceLogo == 666) {
els.cuslgurl.style.display = 'block';
if (settings.vzin) trilog('自定义logo:\n\t' + (settings.cusLogoUrl == "" ? "地址为空" : settings.cusLogoUrl))
}
}
}
function update() {
let i = [];
if (DEFAULT_CONFIG.triSay != UserConfig.triSay) {
triSay(DEFAULT_CONFIG.triSay, NOTICE_TRISAY_KEEPER);
UserConfig.triSay = DEFAULT_CONFIG.triSay;
};
if (getValue("set")) {
setValue("USER_CONFIG", DEFAULT_CONFIG);
delValue("set");
delValue("uct");
i.push("代码重整")
};
if (UserConfig.inputUpDownPosition) {
UserConfig.inputLenTillTop = DEFAULT_CONFIG.inputLenTillTop;
delete UserConfig.inputUpDownPosition;
i.push("变量改动")
};
if (UserConfig.thmColor[1] == "1") {
UserConfig.thmColor = DEFAULT_CONFIG.thmColor;
i.push("色彩重构")
};
if (UserConfig.triLingvo != undefined) {
delete UserConfig.triLingvo;
i.push("言语消散")
};
if (UserConfig.vzin == undefined) {
UserConfig.vzin = false;
i.push("维新的洞察")
};
setValue("USER_CONFIG", UserConfig);
if (i[0] && UserConfig.vzin) trilog('星凰升级完成\n\t升级内容:' + i)
}
//取得用户设定
var UserConfig = getValue("USER_CONFIG", DEFAULT_CONFIG);
update();
trilog('欢迎来到这个星球。');
if (UserConfig.vzin) trilog('维新开始工作。')
let inputLenTillTop = UserConfig.luma ? UserConfig.inputLenTillTop[1] : UserConfig.inputLenTillTop[0];
//预置的必需样式 others tris
// addCss(`:root{--wallpaper: url(` + IMAGES[2] + `)}`);
addCss(TRI_CSS_TEXT.others);
addCss(TRI_CSS_TEXT.tris);
if (UserConfig.pageTiltle) document.title = UserConfig.pageTiltle;
if (UserConfig.pageBackgroundImgBing) {
trequest({
method: "GET",
url: API[1],
onload: (b) => {
let bing = 'https://www.bing.com' + JSON.parse(b.responseText).images[0].url;
addCss(`body{background-image:url(` + bing + `)}`);
if (UserConfig.vzin) trilog('壁纸与微软必应同步:\n\t' + bing)
}
});
};
if (UserConfig.luma) { //luma estas on
addCss(TRI_CSS_TEXT.luma)
$('body')[0].innerHTML = TRI_HTML[0];
} else { //luma estas off
if (UserConfig.searchInputOpt) addCss(TRI_CSS_TEXT.searci);
if (UserConfig.topLeft) addCss(`.s-top-left{display: none}`);
if (UserConfig.userList) {
addCss(`.s-top-right{display: none}`)
}
// else {addCss(`.s-top-right .s-top-login-btn{display: none}`)} //应当不需要这个
if (UserConfig.hotNews) $("#m").remove();
//elogo
let lgs = UserConfig.replaceLogo;
if (lgs) {
let elogo = $("#s_lg_img")[0];
switch (lgs) {
case -2:
elogo.style.opacity = "0";
break;
case -1:
elogo.style.display = "none"; //移除
break;
case 233:
trequest({
method: "GET",
url: API[0],
onload: (r) => {
let bili = JSON.parse(r.responseText).data[142][0].litpic.replace("http:", "https:");
elogo.src = bili;
if (UserConfig.vzin) trilog('logo与哔哩哔哩同步\n\t' + bili)
}
}); //跟随logo
break;
case 666:
elogo.src = UserConfig.cusLogoUrl ? UserConfig.cusLogoUrl : elogo.src;
break;
}
if (lgs > 0 && lgs < 5) { //1-4 四季
elogo.src = LOGO_LIST[lgs - 1]
}
let mp = $("area")[0];
if (lgs != -1) { //-1 移除 无需替换
mp.href = UserConfig.logoLinksTo;
mp.target = UserConfig.targetDeLogo ? "_blank" : "_self";
mp.title = UserConfig.tipDeLogo
}
}
}
let ct = document.createElement('div');
ct.innerHTML = TRI_HTML[1];
try {
document.body.appendChild(ct);
$('#tri-ell')[0].innerHTML = `
body {}
:root{
--ipt-len: ` + inputLenTillTop + `;
--ipt-fz: ` + UserConfig.inputFontSize + `;
--thm-fc: ` + UserConfig.thmColor[0] + `;
--thm-fo: ` + UserConfig.thmColor[1] + `;
--thm-bg: ` + UserConfig.thmColor[2] + `;
--thm-bd: ` + UserConfig.thmColor[3] + `
}
`;
$('#tri-styles')[0].innerHTML = `
body {}
:root{
--ipt-len: ` + inputLenTillTop + `;
--ipt-fz: ` + UserConfig.inputFontSize + `;
--thm-fc: ` + UserConfig.thmColor[0] + `;
--thm-fo: ` + UserConfig.thmColor[1] + `;
--thm-bg: ` + UserConfig.thmColor[2] + `;
--thm-bd: ` + UserConfig.thmColor[3] + `
}
`;
$(document).on('click', '.trilato', () => {
// window.open(IMAGES[1])
triSay("我们的相遇,是一个幸运的开始...", 5)
});
$(document).on('click', '.save-btn', () => {
triSay("记忆装填中...", 1);
setValue("USER_CONFIG", savl(0));
setTimeout(() => {
window.location.reload()
}, 1500)
});
savl(UserConfig);
} catch (e) {
console.log(e)
}
if (UserConfig.vzin) {
console.log(savl(0))
console.timeEnd("星凰·众里寻她千百度\n\t本次耗时")
}
})();