GitHub Repo Share-to-Twitter Button

Add a Twitter share button to repository page

目前为 2021-07-08 提交的版本。查看 最新版本

// ==UserScript==
// @name         GitHub Repo Share-to-Twitter Button
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a Twitter share button to repository page
// @author       eggplants
// @homepage     https://github.com/eggplants
// @match        *://github.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    "use strict";

    owner = document.getElementsByClassName('url fn')[0].textContent
    pjname = document.getElementsByClassName('mr-2 flex-self-stretch')[0].textContent.trim()
    repo = 'https://github.com/' + owner + '/' + pjname

    var a = document.getElementsByClassName('btn ml-2 d-none d-md-block')[0]
    var b = document.createElement('a')
    b.className = 'btn btn-info'
    b.setAttribute('target', '_blank')

    b.href = 'http://twitter.com/share?url=' + repo + '&text=[write comments]%0a%0a'
    b.textContent = 'Share to Twitter'
    a.parentNode.insertBefore(b, a)
}());

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址