Last active
May 28, 2019 02:47
-
-
Save JichunMa/6f503c933325391727262750bc9e1069 to your computer and use it in GitHub Desktop.
Phabricator copy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Phabricator copy | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://code.yangqianguan.com/D* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var button = document.createElement("input"); | |
button.setAttribute("type", "button"); | |
var title_element = document.querySelector("#phabricator-standard-page-body > div.phui-two-column-view.phui-side-column-right.with-subheader > div > div.phui-two-column-header > div > h1 > div > div.phui-header-col2 > span") | |
var title = document.URL+' '+title_element.innerText.trim(); | |
button.setAttribute("value", "Copy"); | |
button.setAttribute('style', 'padding:3px 9px;border-radius:3px;background:rgba(71,87,120,0.1);margin-right:8px;-webkit-font-smoothing:auto;border-color:transparent;font-weight:normal;font-size:14px;margin-top:8px;color:#464C5C'); | |
button.addEventListener("click", function(){ | |
var input = document.createElement('input'); | |
input.setAttribute('value', title); | |
document.body.appendChild(input); | |
input.select(); | |
var result = document.execCommand('copy'); | |
document.body.removeChild(input) | |
}); | |
var head_element = document.querySelector("#phabricator-standard-page-body > div.phui-two-column-view.phui-side-column-right.with-subheader > div > div.phui-two-column-header > div > h1 > div > div.phui-header-col2 > div.phui-header-subheader"); | |
head_element.appendChild(button); | |
} | |
)(); |
hanfeng120
commented
May 28, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment