Copy Tab Title+URL

press ctrl(cmd)-shift-c to copy the tab tile with url in clipboard, e.g., "Stack Overflow - Where Developers Learn, Share, & Build Careers: https://stackoverflow.com/"

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name                  Copy Tab Title+URL
// @name:zh-CN            拷贝标签页标题+链接
// @namespace             http://tampermonkey.net/
// @version               0.1
// @author                Zhou Yucheng
// @description           press ctrl(cmd)-shift-c to copy the tab tile with url in clipboard, e.g., "Stack Overflow - Where Developers Learn, Share, & Build Careers: https://stackoverflow.com/"
// @description:zh-CN     按下 ctrl(cmd)-shift-c 拷贝当前标签页标题+链接至剪贴板,例如在百度首页拷贝为“百度一下,你就知道: www.baidu.com”
// @license               MIT
// @include               *
// @grant                 GM_setClipboard
// ==/UserScript==

// TODO: replace @include with @match *://*/*
(function () {
    'use strict';
    document.addEventListener("keydown", function (e) {
        if ((e.key === 'c' || e.keyCode === 67) && (e.ctrlKey || e.metaKey) && e.shiftKey ) {
            let str = document.title + ": " + location.href;
            GM_setClipboard(str);
            //console.log(str);
        }
    });
})();