Skip to content

Instantly share code, notes, and snippets.

@mohemohe
Last active June 5, 2024 07:23
Show Gist options
  • Save mohemohe/273c5ce2ef0c31ef1c2fc0b89c805196 to your computer and use it in GitHub Desktop.
Save mohemohe/273c5ce2ef0c31ef1c2fc0b89c805196 to your computer and use it in GitHub Desktop.
Backlogの課題番号から該当の課題を直接開くやつ
// ==UserScript==
// @name Backlogの課題番号から該当の課題を直接開くやつ
// @namespace dev.mohemohe.backlog.shortcut
// @match https://*.backlog.jp/*
// @match https://*.backlog.com/*
// @grant none
// @version 1.1
// @author mohemohe
// @description 2024/6/5 15:30:49
// ==/UserScript==
window.addEventListener('keydown', async (e) => {
if (!Backlog?.resource) {
return;
}
if ((e.ctrlKey || e.metaKey) && e.key === "k") {
let issueNum;
while (true) {
issueNum = prompt("課題キーの番号?");
if (!issueNum) {
return;
}
if (!issueNum.match(/\d+/)) {
alert("数値で入力してください");
continue;
}
break;
}
const projectKey = Backlog.resource["project.key"];
const issueKey = `${projectKey}-${issueNum}`;
const issueUrl = `https://${location.hostname}/view/${issueKey}`;
const res = await fetch(issueUrl, {
method: "HEAD",
credentials: "include",
});
if (!res.ok) {
alert("課題が存在しません");
return;
}
location.href = issueUrl;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment