Skip to content

Instantly share code, notes, and snippets.

@yuujii
Last active February 23, 2023 07:27
Show Gist options
  • Save yuujii/9875aa31d4e0fb9f40932e8af1617c15 to your computer and use it in GitHub Desktop.
Save yuujii/9875aa31d4e0fb9f40932e8af1617c15 to your computer and use it in GitHub Desktop.
BingAIに便利なボタンを追加したり中華フォントを修正したりするUserScript BingAI URL: https://www.bing.com/search?q=AI&showconv=1 Edge Plugin: Violentmonkey https://microsoftedge.microsoft.com/addons/detail/violentmonkey/eeagobfjdenkkddmbclomhiblgggliao
// ==UserScript==
// @name BingGPTに便利なボタンを追加する - bing.com
// @namespace https://gist.github.com/yuujii/9875aa31d4e0fb9f40932e8af1617c15
// @version 1.0
// @updateURL https://gist.github.com/yuujii/9875aa31d4e0fb9f40932e8af1617c15/raw/binggpt-custom.user.js
// @match https://www.bing.com/search?*
// @grant none
// @description 2023/2/12 12:06:50
// ==/UserScript==
// Bookmark: https://www.bing.com/search?q=AI&showconv=1
(function(){
'use strict'
// CSS
document.head.insertAdjacentHTML('beforeend', `
<style>
/* 中華フォント修正 */
body {
--cib-font-text: Meiryo, Arial Unicode MS, sans-serif!important;
}
</style>
`);
let isAdded = false;
// const targetNode = document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot;
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
// Unityでボタン
const unityButton = function() {
const btn = `
<div class="button-compose-wrapper">
<button class="button-compose" type="button" aria-label="Unityで" id="unityde">
<div class="button-compose-content">
<svg-icon class="button-compose-icon" type="token" size="32" style="--icon-size:32px;"></svg-icon>
<div class="button-compose-text">Unityで</div>
</div>
</button>
<div class="button-compose-hint">Unityで</div>
</div>
`;
const parentnode = document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("div.outside-left-container");
parentnode.insertAdjacentHTML('afterend', btn);
document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("button#unityde").addEventListener('click', () => {
var ta = document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("textarea");
ta.value = "Unityで、スクリプトを書いてください。冒頭の説明は不要です。スクリプトの説明についてはスクリプト内のクラスヘッダーとメソッドヘッダーにXML Documentで日本語で簡潔なコメントを付けてください。";
ta.focus();
ta.setSelectionRange(7, 7);
});
}
const observer = new MutationObserver(function(mutations, observer) {
for (var i = 0; i < mutations.length; i++) {
if ((mutations[i].target).querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("div.outside-left-container")) {
if (isAdded) return;
isAdded = true;
unityButton();
// FeedBack非表示
const feedbackBox = document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("cib-serp-feedback")
feedbackBox.style.display = "none";
// フォント変更により発生してた1行のときにSearchBoxの縦スクロールが出ていたのを修正
const searchBox = document.querySelector("#b_sydConvCont > cib-serp").shadowRoot.querySelector("#cib-action-bar-main").shadowRoot.querySelector("#searchbox");
searchBox.style.overflow = "hidden";
searchBox.style.fontSize = "14px";
searchBox.style.margin = "1px 0";
}
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment