SurePrintZhihu

try to print to pdf of Zhihu!

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         SurePrintZhihu
// @namespace    http://surewong.com/SurePrint
// @version      0.2
// @description  try to print to pdf of Zhihu!
// @author       SureWong
// @match        https://*.zhihu.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @license      AGPL License
// @grant        none
// ==/UserScript==

/* jshint esversion: 11 */

(function() {
    'use strict';

    // Your code here...
    var surePrintBtn = document.createElement('button')
    surePrintBtn.innerHTML = "准备打印pdf"
    surePrintBtn.className = "sure-print-pdf"

    surePrintBtn.onclick = function (e) {


      // 专栏,例如:https://zhuanlan.zhihu.com/p/78340397
      document.querySelector(".ColumnPageHeader-Wrapper")?.remove();// 顶栏
      document.querySelector(".ContentItem-actions")?.remove();// 底栏
      document.querySelector(".RichContent-actions")?.remove();// 赞同按钮
      document.querySelector(".CornerButtons")?.remove();// 角落按钮

      // 回答,例如:https://www.zhihu.com/question/68482809/answer/264632289
      document.querySelector(".AppHeader")?.remove();// 顶栏
    }

    var body = document.body
    var style = document.createElement('style')
    style.id = "sure-print-pdf"
    var css = `.sure-print-pdf{
      position: fixed;
      bottom: 5%;
      right: 1%;
      width: 70px;
      height: 70px;
      background: lightblue;
      border-radius: 50%;
      font-size: 10px;
      z-index: 999;
      cursor: pointer;
      font-size: 10px;
      overflow: hidden;
    }`
    if (style.styleSheet) {
      style.styleSheet.cssText = css;
    } else {
      style.appendChild(document.createTextNode(css));
    }
    body.appendChild(surePrintBtn)
    body.appendChild(style)


})();