// ==UserScript==
// @name 众里寻她千百度
// @version 5.14
// @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/[email protected]/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
// @grant GM_registerMenuCommand
// @note 5.00 新的开始
// @note 5.01 修复了一个与AC脚本冲突的问题
// @note 5.02 修复了一个问题
// @note 5.03 修复了两个问题 一些细节优化
// @note 5.04 新的LOGO:哔哩哔哩·四季[冬] 现已开放![修复]部分情况下,搜索框样式未能正确被修改
// @note 5.05 体验优化
// @note 5.06 体验优化
// @note 5.07 体验优化:油猴菜单项优化,明了又不失个性
// @note 5.08 修复了一个问题
// @note 5.09 修复了一个问题 亿些细节优化 更多内容与「妖染」中[主题色]同步
// @note 5.10 体验优化 新增「纯白之空·流光」!
// @note 5.11 体验优化 新增「兴亡·星凰言语」!
// @note 5.12 版本号+1
// @note 5.13 版本号+1
// @note 5.14 代码重整 星凰为规范化变量,用户的所有配置将被重置
// ==/UserScript==
(() => {
console.time("星凰·众里寻她千百度\n本次耗时");
const NOTICE_TRISAY_KEEPER = 2000; //triSay时长
const TRI_UPDATE_NOTICE =
`本期:星凰为规范化变量,所有配置将被重置
新的颜色配置
往期:新增「星凰言语」!
`;
const WALLPAPERS = [
"http://g.hiphotos.baidu.com/zhidao/pic/item/8644ebf81a4c510f973523a36b59252dd52aa592.jpg",
"https://cdn.jsdelivr.net/gh/loktindyi/mybaiduhp@master/raw.png"
];
const logolist = [
"", //春
"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, //流光
triLingvo: false, //星凰言语
pageTiltle: "众里寻她千百度", //标题
topLeft: false, //左上角推广
userList: false, //右上角用户
hotNews: false, //新闻
inputUpDownPosition: 90, //搜索框位置
inputFontSize: 20, //字体大小
pageBackgroundImg: WALLPAPERS[0],//背景图片地址
pageBackgroundImgBing: false, //必应背景图
replaceLogo: 233, //logo
cusLogoUrl: "", //自定义logourl
tipDeLogo: "前往哔哩哔哩", //logo提示语
targetDeLogo: false, //跳转方式
logoLinksTo: "https://www.bilibili.com", //链接到
thmColor: ["250 114 152", "1", "1", "1"], //main (op bgop bdop)
triSay: TRI_UPDATE_NOTICE //triSay
};
const TRI_CSS_TEXT = {
triSay: `
box-shadow: 0 0 15px 3px rgba(250, 114, 152, .3);
width: 20%;
min-width: 60px;
background: #fff;
opacity: 0.85;
height: auto;
min-height: 30px;
color: var(--thm-f);
line-height: 30px;
text-align: center;
border-radius: 5px;
position: fixed;
top: 60%;
left: 40%;
z-index: 999999;
`,
searchInput: `
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: #000b;
border-color: var(--thm-bd) !important;
font-size: calc(var(--std-ipt-fz)*1px)
}
#head_wrapper #form .bdsug-new {
position: absolute;
left: 6%;
top: 55px !important;
background-color: #ffffff;
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-f) !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 .head_wrapper {
top: calc(var(--std-ipt-pos)*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: `@-webkit-keyframes twinkling {
0% {
opacity: 0
}
33% {
opacity: 1
}
66% {
opacity: 0
}
100% {
opacity: 1
}
}
.fs-ipt {
padding-left: 5px;
background: #fff8;
border: solid 1px var(--thm-bd);
border-radius: 5px;
outline: none;
height: 18px;
font-size: 60%
}
.ipnum {
width: 12%
}
.Tri-hide-btn,
#Tri-joinus {
box-shadow: 0 0 15px 3px rgba(250, 114, 152, .4);
top: 0;
outline: none;
border: none;
z-index: 99999
}
#Tri-joinus {
position: absolute;
top: 2%;
right: 4%;
width: 24%;
height: 6%;
border-radius: 8px;
background-color: rgba(255, 255, 255, 0.6);
color: var(--thm-f);
-webkit-animation: twinkling 1.5s 1 ease-in-out;
}
.Tri-hide-btn {
position: fixed;
right: 0;
width: 2%;
height: 3%;
border-bottom-left-radius: 8px;
background-color: rgba(255, 255, 255, 0.3);
}
.Tri-settings-page-title {
color: var(--thm-f);
font-size: 23px;
position: absolute;
top: 3%;
left: 3%;
}
#Tri-settings {
position: fixed;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 16px;
border-color: #0000;
padding: 15px;
z-index: 99999;
font-size: 14px;
line-height: 200%;
width: 300px;
height: 600px !important;
top: 5%;
color: #222;
right: 5%;
background-size: cover;
box-shadow: 0 0 15px 3px rgba(250, 114, 152, .3);
background-image: var(--wallpaper)
}
.trilato {
position: absolute;
width: 90%;
height:18%;
cursor: not-allowed;
font-size: large;
color: var(--thm-f)
}`,
luma: `
.trifm {
margin: auto;
top: calc(var(--std-ipt-pos)*1px)
}
#tript {
border-bottom: solid 2px var(--thm-bd);
outline: none;
color: #000b;
background-color: var(--thm-bg);
margin: auto;
height: 40px;
width: 540px;
font-size: 20px;
text-align: center;
}`
};
const LAN = [
{
gm_menu: ["配置", "保存", "重置"],
prompt: ["先点击配置,才能保存", "确定重置吗?", "正在重置...", 1000],
settings_title: "配置众里寻她千百度",
page_title: "设置标题",
search_input: "搜索框优化",
luma: "至简",
lingvo: "星凰言语",
top_left: "移除推广",
user_list: "移除用户",
hot_news: "移除偶现的新闻",
input_updown_position: "搜索框位置",
input_font_size: "字体大小",
page_background_img: ["背景图片", "与微软必应同步", ""],
la_logo: "LOGO",
tip_at_logo: "提示文字",
target_de_logo: ["跳转", "当前页", "新页"],
logo_links_to: "链接URL",
tip_de_placeholder: ["标签页标题", "粘贴图片地址", "鼠标在LOGO上提示文字", "点击LOGO后跳转到这个链接", "RGB格式:255 255 255"],
thm_color: "主题色"
},
{
gm_menu: ["诗篇·命运", "忆海·铭记", "沉落·新生"],
prompt: ["星凰的忆海,装不下未被吟唱的诗篇...", "星凰的记忆...", "丢掉了....", 2500],
settings_title: "众里寻她千百度",
page_title: "真名",
search_input: "维新",
luma: "流光",
lingvo: "TriLingvo",
top_left: "我只要搜索",
user_list: "登陆有啥用",
hot_news: "才不看新闻",
input_updown_position: "太高够不着",
input_font_size: "太小看不清",
page_background_img: ["信仰背景图", "Bing!", ""],
la_logo: "传送门",
tip_at_logo: "引导",
target_de_logo: [">>>", "跃迁", "新世界"],
logo_links_to: "目的地",
tip_de_placeholder: ["", "", "", "", ""],
thm_color: "多彩世界"
}
];
function triSay(msg, duration) {
duration = isNaN(duration) ? 3000 : duration;
var m = document.createElement('div');
m.innerText = msg;
m.style.cssText = TRI_CSS_TEXT.triSay;
document.body.appendChild(m);
setTimeout(() => {
var d = 0.5;
m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
m.style.opacity = '0';
setTimeout(() => {
document.body.removeChild(m)
}, d * 1000);
}, duration);
}
function savl(settings) {
let els = {
search: $('#vsearch')[0],
luma: $('#luma')[0],
lingvo: $('#lingvo')[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]
//Ne triSay
}
if (!settings) {
return {
searchInputOpt: els.search.checked,
luma: els.luma.checked,
triLingvo: els.lingvo.checked,
pageTiltle: els.pagetitle.value,
topLeft: els.topleft.checked,
userList: els.user.checked,
hotNews: els.news.checked,
inputUpDownPosition: els.ipos.value,
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, DEFAULT_CONFIG.thmColor[1], DEFAULT_CONFIG.thmColor[2], DEFAULT_CONFIG.thmColor[3], DEFAULT_CONFIG.thmColor[4]]
}
} else {
els.search.checked = settings.searchInputOpt;
els.luma.checked = settings.luma;
els.lingvo.checked = settings.triLingvo;
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.inputUpDownPosition ? settings.inputUpDownPosition : DEFAULT_CONFIG.inputUpDownPosition;
els.ipfz.value = settings.inputFontSize ? settings.inputFontSize : DEFAULT_CONFIG.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];
if (settings.replaceLogo == 666) {
els.cuslgurl.style.display = 'block'
}
}
}
function update() {
if (GM_getValue("set")) {
GM_setValue("USER_CONFIG", DEFAULT_CONFIG);
GM_deleteValue("set");
GM_deleteValue("uct")
};
if (DEFAULT_CONFIG.triSay != UserConfig.triSay) {
triSay(DEFAULT_CONFIG.triSay, NOTICE_TRISAY_KEEPER);
UserConfig.triSay = DEFAULT_CONFIG.triSay;
GM_setValue("USER_CONFIG", UserConfig)
};
// console.log('待编写升级函数')
}
//取得用户设定
var UserConfig = GM_getValue("USER_CONFIG", DEFAULT_CONFIG);
update();
let lingvo = UserConfig.triLingvo ? LAN[1] : LAN[0]
//预置的必需样式 others tris
GM_addStyle(`
:root {
--a: ` + DEFAULT_CONFIG.thmColor[1] + `;
--b: 0;
--c: 1;
--thm-f: rgb(var(--thm-main) / var(--a));
--thm-bg: rgb(var(--thm-main) / var(--b));
--thm-bd: rgb(var(--thm-main) / var(--c));
--std-ipt-fz: ` + UserConfig.inputFontSize + `;
--std-ipt-pos: ` + UserConfig.inputUpDownPosition + `;
--wallpaper: url(` + WALLPAPERS[1] + `)
}`);
GM_addStyle(TRI_CSS_TEXT.others);
GM_addStyle(TRI_CSS_TEXT.tris);
// GM_addStyle();
if (UserConfig.pageTiltle) {
document.title = UserConfig.pageTiltle
}
if (UserConfig.pageBackgroundImgBing) {
GM_xmlhttpRequest({
method: "GET",
url: API[1],
onload: function (b) {
GM_addStyle(`body{background-image:url('https://www.bing.com` + JSON.parse(b.responseText).images[0].url + `')}`)
}
});
}
else if (UserConfig.pageBackgroundImg != "") {
GM_addStyle(`body{background-image:url('` + UserConfig.pageBackgroundImg + `')}`)
}
;
if (UserConfig.luma) { //luma estas on
GM_addStyle(TRI_CSS_TEXT.luma)
$('body')[0].innerHTML = `
<form action="/s" class="trifm">
<input id="tript" type="text" name="wd" autocomplete="off" autofocus>
</form>`;
} else { //luma estas false
if (UserConfig.searchInputOpt) {
GM_addStyle(TRI_CSS_TEXT.searchInput)
}
if (UserConfig.topLeft) {
GM_addStyle(`.s-top-left{display: none}`)
}
if (UserConfig.userList) {
GM_addStyle(`.s-top-right{display: none}`)
}// else {GM_addStyle(`.s-top-right .s-top-login-btn{display: none}`)} //应当不需要这个
if (UserConfig.hotNews) {
$("#m").remove()
};
//la_logo
let lgs = UserConfig.replaceLogo;
if (lgs) {
var la_logo = $("#s_lg_img")[0];
switch (lgs) {
case -2:
la_logo.style.opacity = "0";
break;
case -1:
la_logo.style.display = "none"; //移除
break;
case 233:
GM_xmlhttpRequest({
method: "GET",
url: API[0],
onload: function (r) {
la_logo.src = JSON.parse(r.responseText).data[142][0].litpic.replace("http:", "https:");
}
}); //跟随logo
break;
case 666:
la_logo.src = UserConfig.cusLogoUrl ? UserConfig.cusLogoUrl : la_logo.src;
break;
}
if (lgs > -1 && lgs < 4) {
la_logo.src = logolist[lgs - 1]
}
let mp = $("area")[0];
if (lgs != -1) {
mp.href = UserConfig.logoLinksTo;
mp.target = UserConfig.targetDeLogo ? "_blank" : "_self";
mp.title = UserConfig.tipDeLogo;
} //-2.替换链接但不显示logo
}
}
let ct = document.createElement('div');
ct.id = "tricontr";
ct.style.display = "block";//"none";
ct.innerHTML = `
<input type="button" class="Tri-hide-btn" onclick="$('#Tri-fs')[0].style.display = $('#Tri-fs')[0].style.display == 'none'?'block':'none'">
<div id="Tri-settings" style="user-select:none;display: block">
<fieldset id="Tri-fs" class="Tri-settings">
<legend class="Tri-settings-page-title">`+ lingvo.settings_title + `</legend>
<input id="Tri-joinus" type="button" onclick="window.open('https://jq.qq.com/?wv=1027&k=IMqY916N')"
value="加入星凰">
<div style="text-align:left">
<br><br>
<hr>
<label><input id="vsearch" type="checkbox"> `+ lingvo.search_input + `    </label>
<label><input id="luma" type="checkbox"><font style="color: var(--thm-f)"> `+ lingvo.luma + `    </font></label>
<label><input id="lingvo" type="checkbox"><font style="color: var(--thm-f)"><b> `+ lingvo.lingvo + `</b></font></label><br>
`+ lingvo.page_title + ` <label><input id="pagetitle" type="text" class="fs-ipt" placeholder="` + lingvo.tip_de_placeholder[0] + `"></label><br>
<label><input id="topleft" type="checkbox"> `+ lingvo.top_left + ` </label>
<label><input id="vuser" type="checkbox"> `+ lingvo.user_list + ` </label>
<label><input id="vnews" type="checkbox"> `+ lingvo.hot_news + `</label><br>
`+ lingvo.input_updown_position + ` <label><input id="ipos" type="number" class="fs-ipt ipnum" placeholder="90"></label>
`+ lingvo.input_font_size + ` <label><input id="ipfz" type="number" class="fs-ipt ipnum" placeholder="16"></label><br>
`+ lingvo.page_background_img[0] + `          <label><input id="bgimg-bing" type="checkbox"> ` + lingvo.page_background_img[1] + ` </label><br>
<label><input id="bgimg" style="width:70%" type="text" class="fs-ipt" placeholder="` + lingvo.tip_de_placeholder[1] + `"></label><br>
<label>`+ lingvo.la_logo + `
<select id="vlogo" onchange="$('#cuslgurl')[0].style.display=$('#op666')[0].selected?'block':'none'" style="height: 16px;font-size:12px;outline:none">
<option value="0">不替换</option>
<option value="-2">隐藏式</option>
<option value="-1">移除</option>
<option value="1" style="color:#9ECE60" disabled>哔哩哔哩·春(暂无)</option>
<option value="2" style="color:#FF2B43">哔哩哔哩·夏</option>
<option value="3" style="color:#FF7621">哔哩哔哩·秋</option>
<option value="4" style="color:#56B5F6">哔哩哔哩·冬</option>
<option value="233" style="color:#fa7298">与哔哩哔哩同步</option>
<option value="666" id="op666">自定义</option>
</select>
<input id="cuslgurl" type="text" class="fs-ipt" style="position:absolute;right:10%;top:39%;width:30%;display:none" placeholder="`+ lingvo.tip_de_placeholder[1] + `"></label><br>
`+ lingvo.tip_at_logo + ` <label><input id="lgtip" type="text" class="fs-ipt" style="width:30%" placeholder="` + lingvo.tip_de_placeholder[2] + `"></label><br>
`+ lingvo.target_de_logo[0] + ` <label><input id="lgtars" type="radio" name="target_de_logo"> ` + lingvo.target_de_logo[1] + ` </label>
<label><input id="lgtar" type="radio" name="target_de_logo"> `+ lingvo.target_de_logo[2] + `</label><br>
`+ lingvo.logo_links_to + ` <label><input id="lglinksto" type="text" value="https://www.bilibili.com" class="fs-ipt" style="width:50%" placeholder="` + lingvo.tip_de_placeholder[3] + `"></label><br>
<!--<label><input id="ipfz" type="number" class="fs-ipt ipnum" placeholder="16"></label>-->
`+ lingvo.thm_color + ` <label><input id="thmcolor0" type="text" class="fs-ipt" style="" onkeyup="$('#tristyle-color')[0].innerHTML=':root{--thm-main:'+this.value+';}'" placeholder="` + lingvo.tip_de_placeholder[4] + `"></label><br>
<br><br><br><br>
<span class="trilato" onclick="window.open('` + WALLPAPERS[1] + `')">世人多为笼中鸟<br><font style="position:absolute;right:0">尘土之上有星空</font></span>
<style id="tristyle-color" type="text/css">:root{--thm-main: ` + DEFAULT_CONFIG.thmColor[0] + `;}</style>`;
try {
document.body.appendChild(ct);
savl(UserConfig);
} catch (e) {
console.log(e)
}
//console.log(savl(0));
console.timeEnd("星凰·众里寻她千百度\n本次耗时")
GM_registerMenuCommand(lingvo.gm_menu[0], () => {
$("#tricontr")[0].style.display = "block";
});
GM_registerMenuCommand(lingvo.gm_menu[1], () => {
if ($("#tricontr")[0].style.display == "block") {
GM_setValue("USER_CONFIG", savl(0));
setTimeout(() => {
window.location.reload()
}, 200);
} else {
triSay(lingvo.prompt[0], 2500)
}
});
GM_registerMenuCommand(lingvo.gm_menu[2], () => {
if (confirm(lingvo.prompt[1])) {
triSay(lingvo.prompt[2], lingvo.prompt[3]);
GM_deleteValue("USER_CONFIG");
setTimeout(() => {
window.location.reload()
}, 2000)
}
});
})();