1

I am looking for a Google Chrome extension that allow the user to place the title of the current tab in the clipboard with a keyboard shortcut. It should work on Microsoft Windows.

There seems to be no way to do it natively: https://support.google.com/chrome/answer/157179?hl=en

enter image description here

2

You may use the Shortcut manager chrome extension.


Steps:

  1. Install the extention
  2. Open the extention

    enter image description here

  3. Click Add a new Shortcut (1)

  4. Assign a shortcut (2). I used ctrl+Alt+k
  5. Select Execute Javascript (3)
  6. In the field shown as (4) copy the following javascript
function clip(text) {
    var copyElement = document.createElement('input');
    copyElement.setAttribute('type', 'text');
    copyElement.setAttribute('value', text);
    copyElement = document.body.appendChild(copyElement);
    copyElement.select();
    try {
        if(!document.execCommand('copy')) throw 'Not allowed.';
    } catch(e) {
        copyElement.remove();
        console.log("document.execCommand('copy'); is not supported");
        prompt('Copy the text below. (ctrl c, enter)', text);
    } finally {
        if (typeof e == 'undefined') {
            copyElement.remove();
        }
    }
}
var title = document.getElementsByTagName("title")[0].innerHTML;
clip(title);
  1. Click Save
  2. Restart chrome

Note: The document.execCommand() used in the code is not supported on a few sites for example Wikipedia. But you should be able to circumvent it by changing the javascript or by manually pasting the above code on the console.


References:

  1. Copy to clipboard script taken from here.
  2. Scrip to get the title of the current page is here.
0
1

If you've got a userscript manager installed, such as Tampermonkey, you can use this userscript:

// ==UserScript==
// @name         Quick page title copier
// @namespace    http://stackexchange.com/users/4337810/
// @version      1.0
// @description  A userscript that lets you quickly copy the title of a webpage
// @author       α”•α–Ία˜Žα•Š (http://stackexchange.com/users/4337810/)
// @match        *://*
// @grant        none
// ==/UserScript==

(function() {
    document.addEventListener('keyup', function(e) {
        if(e.ctrlKey && e.shiftKey && e.keyCode == 67) {
            window.prompt('Press Ctrl+C', document.getElementsByTagName("title")[0].innerHTML);
        }
    }, false);
})();

It doesn't directly copy, like @Aswin's script, but it prompts you so you can just ctrl+c it.

Default shortcut is ctrl+shift+c

Your Answer

By clicking β€œPost Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.