bookmarklet



for zero trust

javascript:(function(){
  // Create input box (no background overlay)
  const box = document.createElement("div");
  Object.assign(box.style, {
    position: "fixed",
    top: "20px",
    left: "50%",
    transform: "translateX(-50%)",
    background: "#fff",
    padding: "12px 20px",
    borderRadius: "8px",
    fontSize: "16px",
    boxShadow: "0 2px 8px rgba(0,0,0,0.2)",
    zIndex: 99999,
  });
  box.innerHTML = `
    <div>⏰ Enter minutes to subtract:</div>
    <input id="myInput" style="width:100px; padding:6px; font-size:16px; margin-top:6px;">
  `;
  document.body.appendChild(box);

  const input = document.getElementById("myInput");
  input.focus();

  function finish(){
    const raw = input.value.trim();
    box.remove();

    // Convert Zenkaku → Hankaku digits
    const val = raw.replace(/[0-9]/g, d => String.fromCharCode(d.charCodeAt(0) - 65248));
    const now = new Date();

    if(val){
      const mins = parseInt(val, 10);
      if(!isNaN(mins)) now.setMinutes(now.getMinutes() - mins);
      else { alert("❌ Please enter a valid number"); return; }
    }

    const pad = n => (n < 10 ? '0' + n : n);
    const result = pad(now.getHours()) + ':' + pad(now.getMinutes());

    navigator.clipboard.writeText(result).then(() => {
      const popup = document.createElement("div");
      popup.textContent = result;
      Object.assign(popup.style, {
        position: "fixed",
        top: "20px",
        left: "50%",
        transform: "translateX(-50%)",
        background: "rgba(0,0,0,0.85)",
        color: "#fff",
        padding: "10px 20px",
        borderRadius: "8px",
        fontSize: "16px",
        zIndex: 100000,
        transition: "opacity 0.3s"
      });
      document.body.appendChild(popup);

      // Fade out and remove
      setTimeout(() => {
        popup.style.opacity = "0";
        setTimeout(() => popup.remove(), 300);
      }, 600);
    });
  }

  // Handle Enter or Space
  input.addEventListener("keydown", e => {
    if (e.key === "Enter" || e.key === " ") {
      e.preventDefault();
      finish();
    }
  });

  // Handle Zenkaku space (full-width " ") after IME composition
  input.addEventListener("compositionend", e => {
    const v = e.target.value;
    if (v.endsWith(" ")) { // Full-width space
      e.target.value = v.slice(0, -1); // Remove it
      finish();
    }
  });
})();

==============================================

Snow Time for log

javascript:(function(){
  // === Create floating input box ===
  var overlay = document.createElement("div");
  overlay.style.position = "fixed";
  overlay.style.top = "0";
  overlay.style.left = "0";
  overlay.style.width = "100%";
  overlay.style.height = "100%";
  overlay.style.display = "flex";
  overlay.style.justifyContent = "center";
  overlay.style.alignItems = "flex-start";
  overlay.style.paddingTop = "40px";
  overlay.style.zIndex = 9999;
  overlay.style.background = "transparent";

  var box = document.createElement("div");
  box.style.background = "#fff";
  box.style.border = "1px solid #ccc";
  box.style.borderRadius = "8px";
  box.style.padding = "16px 20px";
  box.style.boxShadow = "0 2px 10px rgba(0,0,0,0.2)";
  box.style.textAlign = "center";
  box.style.fontSize = "16px";
  box.style.width = "260px";

  var label = document.createElement("div");
  label.textContent = "⏰ Enter a 4-digit number (HHMM)";
  label.style.marginBottom = "10px";

  var input = document.createElement("input");
  input.type = "text";
  input.placeholder = "-1200 for yesterday, empty = now";
  input.style.width = "100%";
  input.style.padding = "8px";
  input.style.fontSize = "16px";
  input.style.border = "1px solid #ccc";
  input.style.borderRadius = "6px";
  input.style.textAlign = "center";

  box.appendChild(label);
  box.appendChild(input);
  overlay.appendChild(box);
  document.body.appendChild(overlay);
  input.focus();

  // Allow space, Enter, or Zenkaku-space to confirm
  input.addEventListener("keydown", function(e){
    if(e.key === " " || e.key === "Enter"){  // space or enter
      e.preventDefault();
      processInput(input.value);
    } else if(e.key === "Escape"){
      overlay.remove();
    }
  });

  // Handle Zenkaku-space after IME composition
  input.addEventListener("compositionend", function(e){
    const v = e.target.value;
    if (v.endsWith(" ")) { // Full-width space
      e.target.value = v.slice(0, -1); // Remove it
      processInput(e.target.value);
    }
  });

  function processInput(val){
    overlay.remove(); // remove input box
    var now = new Date();

    function pad(n){ return (n < 10 ? '0' + n : n); }

    let dateTimeStr;

    if(val.trim() === ""){
      // current date/time
      dateTimeStr = now.getFullYear() + "-" + pad(now.getMonth()+1) + "-" + pad(now.getDate()) +
                    " " + pad(now.getHours()) + ":" + pad(now.getMinutes());
    } else {
      val = val.replace(/[0-9]/g, d => String.fromCharCode(d.charCodeAt(0)-65248));
      let yesterday = /^[-ー]/.test(val);
      if(yesterday) val = val.replace(/^[-ー]/, '');
      val = val.replace(/\D/g, "");
      if(val.length !== 4){
        alert("❌ Please enter exactly 4 digits");
        return;
      }
      let hh = val.substring(0,2), mm = val.substring(2,4);
      if(yesterday) now.setDate(now.getDate() - 1);
      dateTimeStr = now.getFullYear() + "-" + pad(now.getMonth()+1) + "-" + pad(now.getDate()) +
                    " " + hh + ":" + mm;
    }

    navigator.clipboard.writeText(dateTimeStr).then(function(){
      showPopup(dateTimeStr);
    }).catch(function(){
      alert("❌ Failed to copy");
    });
  }

  function showPopup(text){
    var popup = document.createElement("div");
    popup.textContent = text;
    popup.style.position = "fixed";
    popup.style.top = "10px";
    popup.style.left = "50%";
    popup.style.transform = "translateX(-50%)";
    popup.style.background = "rgba(0,0,0,0.85)";
    popup.style.color = "#fff";
    popup.style.padding = "10px 20px";
    popup.style.borderRadius = "8px";
    popup.style.fontSize = "16px";
    popup.style.zIndex = 99999;
    popup.style.boxShadow = "0 2px 10px rgba(0,0,0,0.3)";
    popup.style.transition = "opacity 0.3s";
    document.body.appendChild(popup);
    setTimeout(() => {
      popup.style.opacity = "0";
      setTimeout(() => popup.remove(), 300);
    }, 1200);
  }
})();

For snow Time for action

javascript:(function(){
  // === Create compact input box at top ===
  var inputBox = document.createElement("input");
  inputBox.type = "text";
  inputBox.placeholder = "⏰ 4-digit time (HHMM), use - for yesterday, empty = now";
  Object.assign(inputBox.style, {
    position: "fixed",
    top: "20px",
    left: "50%",
    transform: "translateX(-50%)",
    padding: "6px 10px",
    fontSize: "16px",
    border: "1px solid #aaa",
    borderRadius: "6px",
    background: "rgba(255,255,255,0.9)",
    boxShadow: "0 2px 6px rgba(0,0,0,0.2)",
    textAlign: "center",
    zIndex: 99999,
    width: "260px"
  });
  document.body.appendChild(inputBox);
  inputBox.focus();

  // Confirm with Space or Enter
  inputBox.addEventListener("keydown", function(e){
    if(e.key === " " || e.key === "Enter"){  // half-width space or enter
      e.preventDefault();
      processInput(inputBox.value);
    } else if(e.key === "Escape"){
      inputBox.remove();
    }
  });

  // Detect Zenkaku-space after IME input
  inputBox.addEventListener("compositionend", function(e){
    const val = e.target.value;
    if (val.endsWith(" ")) { // full-width space
      e.target.value = val.slice(0, -1); // remove the full-width space
      processInput(e.target.value);
    }
  });

  function processInput(val){
    inputBox.remove();
    var now = new Date();
    function pad(n){ return (n < 10 ? '0' + n : n); }
    let dateTimeStr;

    if(val.trim() === ""){
      // Current date/time
      dateTimeStr = now.getFullYear() + "-" + pad(now.getMonth()+1) + "-" + pad(now.getDate()) +
                    " " + pad(now.getHours()) + ":" + pad(now.getMinutes()) + ":00";
    } else {
      // Convert full-width digits to half-width
      val = val.replace(/[0-9]/g, d => String.fromCharCode(d.charCodeAt(0)-65248));

      // Check for yesterday mark (- or ー)
      let yesterday = /^[-ー]/.test(val);
      if(yesterday) val = val.replace(/^[-ー]/, '');

      // Keep only digits
      val = val.replace(/\D/g, "");
      if(val.length !== 4){
        alert("❌ Please enter exactly 4 digits");
        return;
      }

      let hh = val.substring(0,2), mm = val.substring(2,4);
      if(yesterday) now.setDate(now.getDate() - 1);

      dateTimeStr = now.getFullYear() + "-" + pad(now.getMonth()+1) + "-" + pad(now.getDate()) +
                    " " + hh + ":" + mm + ":00";
    }

    // Copy to clipboard
    navigator.clipboard.writeText(dateTimeStr).then(function(){
      showPopup(dateTimeStr);
    }).catch(function(){
      alert("❌ Failed to copy");
    });
  }

  function showPopup(text){
    var popup = document.createElement("div");
    popup.textContent = text;
    Object.assign(popup.style, {
      position: "fixed",
      top: "0px",
      left: "50%",
      transform: "translateX(-50%)",
      background: "rgba(0,0,0,0.85)",
      color: "#fff",
      padding: "8px 16px",
      borderRadius: "6px",
      fontSize: "16px",
      zIndex: 999999,
      boxShadow: "0 2px 10px rgba(0,0,0,0.3)",
      transition: "opacity 0.3s"
    });
    document.body.appendChild(popup);
    setTimeout(() => {
      popup.style.opacity = "0";
      setTimeout(() => popup.remove(), 300);
    }, 1200);
  }
})();

==============================================

for excel

javascript:(function(){
  var now = new Date();

  // Pad hours and minutes
  var pad = n => (n < 10 ? '0' + n : n);

  var datetime = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate() +
                 ' ' + pad(now.getHours()) + ':' + pad(now.getMinutes());

  // Combine with tab
  var text = "\t" + "高山(大)" + "\t" + datetime;

  // Copy to clipboard
  navigator.clipboard.writeText(text).then(function(){
    // === Popup (same style as previous) ===
    var popup = document.createElement("div");
    popup.textContent = "excel";
    popup.style.position = "fixed";
    popup.style.top = "0px";
    popup.style.left = "50%";
    popup.style.transform = "translateX(-50%)";
    popup.style.background = "rgba(0,0,0,0.85)";
    popup.style.color = "#fff";
    popup.style.padding = "8px 16px";
    popup.style.borderRadius = "6px";
    popup.style.fontSize = "16px";
    popup.style.zIndex = 999999;
    popup.style.boxShadow = "0 2px 10px rgba(0,0,0,0.3)";
    popup.style.transition = "opacity 0.3s";
    document.body.appendChild(popup);

    // Fade out & remove after 1.2 sec
    setTimeout(() => {
      popup.style.opacity = "0";
      setTimeout(() => popup.remove(), 300);
    }, 1200);
  }).catch(function(){
    alert("❌ Failed to copy");
  });
})();

コメント