Stack Overflow: StackPrinter Mod

Add Printer-Friendly button to question. This script is forked from https://greatest.deepsurf.us/en/scripts/12350-stack-overflow-stackprinter

Versione datata 02/10/2019. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name           Stack Overflow: StackPrinter Mod
// @namespace      https://kaspars.lv
// @description    Add Printer-Friendly button to question. This script is forked from https://greatest.deepsurf.us/en/scripts/12350-stack-overflow-stackprinter
// @include        http*://stackoverflow.com/questions/*
// @include        http*://serverfault.com/questions/*
// @include        http*://superuser.com/questions/*
// @include        http*://stackapps.com/questions/*
// @include        http*://meta.stackoverflow.com/questions/*
// @include        http*://*.stackexchange.com/questions/*
// @include        http*://askubuntu.com/questions/*
// @include        http*://answers.onstartups.com/questions/*
// @include        http*://meta.mathoverflow.net/questions/*
// @include        http*://mathoverflow.net/questions/*
// @version        1.0
// @grant          none
// ==/UserScript==

function ScriptContent () {
  var re = new RegExp('^http[s]*://(.*?).(com|net|org)');
  var group = re.exec(window.location.href);
  var service = group[1];
  var question = document.getElementById("question").dataset.questionid;
  var url = 'http://www.stackprinter.com/export?format=HTML&service=' + service + '&question=' + question;

  function openUrl() {
    if(!window.open(url)) {
      location.href=url;
    }
  }

  var printDiv = document.createElement('div');
  printDiv.id = 'PrinterFriendly';
  printDiv.style.marginTop = '8px';

  var linkAnchor = document.createElement('a');
  linkAnchor.title = 'StackPrinter';
  linkAnchor.addEventListener('click', openUrl, false);

  var image = document.createElement('img');
  image.style.width = '33px';
  image.style.height = '33px';
  image.src = 'data:image/gif;base64,R0lGODlhJwAoAPcAADQ0NDY2Njo6Oj09PT4+PkFBQUNDRkVFRUZGRkdHR0lJSUpKSktLS0xMTE1NTU5OTk9PT05OUVBQUFFRUVJSUlNTU1VVVVhYWFpaWltbW11dXV9fX1paal9fdWBgYGFhYWRkZGZmZmdnZ2BgamhoaGxsbG5ubm9vb25ue3BwcHFxcXJycnR0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e319fX5+fn9/f2dngW1vknZ2gHd3inx9p3+eb3evWnq/V36BrH+DrYGgcYCAgIGBgYKCgoODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJKSkpSUlJaWlpeXl5mZmZqampubm5ycnJ2dnZ6enp+fn4aGrYSIpYqKrI+PsYqVv4uVv5CRrpCQs5KSuJ2dt6CgoKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+vr6amsK6uu7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7Ozubi4uLm5ubq6uru7u7y8vL29vb6+vr+/v5OTwpKizJu65pm8/6urxa2txq6ux6+vyKi32bCwybOzybOzzLe3zrK82bi/2a225qaz/5/C/6LF/6XI/6jM/6zK/6rQ/63W/7nF/7LU+bDX/7Xa/7fb/7nT/77f/8DAwMHBwcPDw8TExMXFxcbGxsfHx8jIyMrKysvLy8zMzM3Nzc7Ozs/Pz8TE18zM1szM3dDQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19TU2tjY2NnZ2dra2tvb297e3t/f38bU8szW/8rb8tTU4Mjk/8/n/9/h7N7j8d/m8t/m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B595OEFCgJn0Us77LhBwQEYFNEKPQ3hEw4iHhxQBTuqrHFCBDcsYsYw+mxDRAIKbCAFLOHw/BA916TxwAMaBCDAAQ0YcAMeJAwAAQlX3FKOghG5EwwSDTTgwROBIJICAxWsAEcfMev4JlQ5sNgRjDrz3PPNKn9cM1ZWjDfu+OOQKxQQAAA7';

  linkAnchor.appendChild(image);
  printDiv.appendChild(linkAnchor);

  var elementVote = document.getElementsByClassName('js-voting-container')[0];
  elementVote.appendChild(printDiv);
}

function AddScript() {
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.text = ScriptContent.toString() + 'ScriptContent();';
  document.body.appendChild(script);
}

AddScript();