🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

Stack Overflow: StackPrinter

Add Printer-Friendly button to question. This script is forked from http://userscripts-mirror.org/scripts/show/77298 and it add supports for HTTPs

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name           Stack Overflow: StackPrinter
// @namespace      http://userscripts.org/users/gangsta75
// @description    Add Printer-Friendly button to question. This script is forked from http://userscripts-mirror.org/scripts/show/77298 and it add supports for HTTPs
// @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        4.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 = 'Printer-Friendly';
  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/Pz8TE18zM1szM3dDQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19TU2tjY2NnZ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QtdQwYAJwRgbTiFkzkHABAEP7Eo4+tDyAgJOtLXQOrXAUAAR4aiKiB595OEFCgJn0Us77LhBwQEYFNEKPQ3hEw4iHhxQBTuqrHFCBDcsYsYw+mxDRAIKbCAFLOHw/BA916TxwAMaBCDAAQ0YcAMeJAwAAQlX3FKOghG5EwwSDTTgwROBIJICAxWsAEcfMev4JlQ5sNgRjDrz3PPNKn9cM1ZWjDfu+OOQKxQQAAA7'
    
  linkAnchor.appendChild(image);
  printDiv.appendChild(linkAnchor);

  var elementQuestion = document.getElementById('question');
  var elementVote = document.getElementsByClassName('votecell')[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();