4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

✅タスクチケット共有用の拡張機能ボタンを作った【Redmine】

Last updated at Posted at 2025-07-21

機能

拡張機能のアイコンをクリックすると、Redmineタスク共有用のチケットタイトルとページURLがクリップボードにコピーされる

↓のチケットリンク作成用文字列をPluginなしでコピペしたいという動機でした。

背景

私の参画するプロジェクトでは、Redmine上でタスクの管理を行っています。
(例)
image.png
タスクの依頼や共有の際にはURL等をコピペしてチャットツールで共有することになりますが、人によってURLのみ ex) https://127.0.0.1.xxx.jp/issues/00001 で送る人やハイパーリンク ex) EX0001_詳細設計書 で送る人などまちまちな状況です。
受け取る側としても、クリックしないでタイトルが分かる方がいいという意見とチケット番号で検索した際にヒットしないのでハイパーリンクはやめてほしいという意見があり、組織内での統一はできていません。
タイトルとURLを両方表記してくれる ex) EX0001_詳細設計書 https://127.0.0.1.xxx.jp/issues/00001 親切な方もいるのですが、やり方を聞いてみたところ別々にコピペしているとのことだったので、私には面倒くさすぎました...。

実装

私のプロジェクトで使用しているRedmineの仕様に合わせて要素を取得しているので、適宜カスタマイズしてください。

background.js
chrome.action.onClicked.addListener((tab) => {
  chrome.scripting.executeScript({
    target: { tabId: tab.id },
    func: () => {
      const url = window.location.href;
      const h3Elements = document.querySelectorAll("#content .subject h3");
      const h3Texts = Array.from(h3Elements).map(el => el.textContent.trim()).join("\n");

      const combinedText = `${h3Texts}\n${url}\n`;

      navigator.clipboard.writeText(combinedText)
        .then(() => alert("チケット内容をクリップボードにコピーしました!"))
        .catch(err => console.error("コピーに失敗しました:", err));
    }
  });
});

URLをwindow.location.hrefで取得し、チケットタイトルをhtml要素から探して取得しています。最終的に以下のような内容がクリップボードに保存されます。

EX0001_詳細設計書
https://redmine.xxx.jp/issues/00001

おわりに

5分程度で作った簡単な機能ですが、結構手数が減って楽になりました!
業務効率化の観点では3日程度で元がとれそうです。

Chromeウェブストア

審査中

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?