Skip to content

Instantly share code, notes, and snippets.

View kohki-shikata's full-sized avatar

Kohki SHIKATA kohki-shikata

View GitHub Profile
// 変数の初期設定
let currentIndex = 0;
const lines = document.querySelectorAll('.main-article h2, .main-article p');
// 行にハイライトを追加する関数
function highlightLine(lineIndex) {
lines.forEach(line => line.classList.remove('kaisei-active'));
// 条件に合った行にハイライトを追加
if (lineIndex >= 0 && lineIndex < lines.length) {
let isEnabled = false; // フラグを初期化
let selectedElement = null; // 現在選択されている要素を保持
// ページロード時にユニーククラスを適用
document.addEventListener('DOMContentLoaded', () => {
applyUniqueClasses();
toggleSelectionMode(false); // 初期状態で選択モードを無効にする
});
// 選択モードの切り替えボタン
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router';
const app = createApp(App)
app.use(router)
app.mount('#app')
// chrome.runtime.onInstalled.addListener(() => {
// console.log("Extension installed!");
// });
// src/background/service-worker.js
let myVariable = "This is a variable from the background script.";
chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => {
if (request.action === "getVariable") {
<script setup lang="ts">
import Sidebar from './components/Sidebar.vue';
import { onMounted, ref } from 'vue';
const fontSize = ref(100); // 初期フォントサイズを100%
// 初期値をストレージから取得
onMounted(() => {
chrome.storage.local.get(['fontSize'], (result) => {
fontSize.value = result.fontSize || 100;
@kohki-shikata
kohki-shikata / content.ts
Last active September 21, 2024 03:51
content.ts
const title = document.querySelector('h1')
if(title) {
title.style.color = 'red'
}
// interface Request {
// fontSize: number;
// }
// // 例えば、requestを以下のように定義する
@kohki-shikata
kohki-shikata / main.md
Created September 16, 2024 12:51
VaultWarden 移行まとめ

SQLiteからMySQLへ変換

  1. 公式に、マイグレの方法が書いてあった
  2. Pythonに、変換パッケージがあるらしい
  3. 手作業で書き換えることも可能らしい

手順

  1. 変換したMySQLダンプファイルを、本番MySQLにインポート
  2. ローカルにディレクトリを作り、Docker PullでVaultwardenの公式イメージを落としてくる
  3. Dockerを起動し、Vaultwardenイメージを実行
  4. ローカルで問題なく動くことを確認
@kohki-shikata
kohki-shikata / delayedProcess.ts
Created July 15, 2024 04:28
逐次処理をPromise.allで非同期に並列処理したいが、少しだけディレイを入れたい(APIの制限対策など)
const delayFunc = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
const syncronusProcess = async (
flag: string | undefined,
time: number = 1000,
iteration: number = 4,
) => {
let i = 1;
while (i <= iteration) {
@kohki-shikata
kohki-shikata / createRandom.test.ts
Created July 8, 2024 03:03
[Node.js]ランダムな整数を出力する(テスト)
// テストにはJestを使用
import { createRandom } from "../functions/helpers";
describe('Create random number between two value: Normal Pattern', () => {
test('Return random value is correct', () => {
const min = 1;
const max = 5;
expect(createRandom(min, max)).toBeLessThanOrEqual(max)
expect(createRandom(min, max)).toBeGreaterThanOrEqual(min)
@kohki-shikata
kohki-shikata / createRandom.ts
Last active July 8, 2024 03:02
[TypeScript] ランダムな整数を返却する。
// 配列をランダムに出力したいときの添字出力用
// バリデーションには、Joiを使用
// 負の値、小数点には対応しない
import Joi from 'joi'
const schema = Joi.object().keys({
min: Joi.number().min(0),
max: Joi.number().positive()
})