GitHub Repo Share-to-Twitter Button

Add a Twitter share button to repository page

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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        https://github.com/*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(window.onload = function() {
    "use strict";

    const description = document.title;
    const pg_link = location.href;

    var a = document.getElementsByClassName('pagehead-actions flex-shrink-0 d-none d-md-inline')[0];
    var b = document.createElement('a');
    b.className = 'btn btn-sm';
    b.setAttribute('target', '_blank');
    b.href = 'http://twitter.com/share?text="' + description + '"%0a%0a' + pg_link;
    b.textContent = 'Share to Twitter';

    var c = document.createElement('li');
    c.appendChild(b);

    a.insertBefore(c, document.getElementsByClassName('pagehead-actions flex-shrink-0 d-none d-md-inline')[0].children[0]);
}());