CTT: CSDN文章迁移到头条自动化脚本

油猴脚本,如果有用请点赞收藏,关注此专栏。谢谢。

// ==UserScript==
// @name         CTT
// @namespace    https://fizzz.blog.csdn.net/
// @version      0.1
// @description  try to take over the world!
// @author       Fizz
// @match        https://**.csdn.net/**/**
// @match        https://mp.toutiao.com/profile_v4/graphic/publish
// @require      https://lib.baomitu.com/jquery/3.5.0/jquery.js
// @require      https://cdn.staticfile.org/html2canvas/0.5.0-beta4/html2canvas.min.js
// @run-at       document-end
// @grant        GM_addStyle
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_addValueChangeListener
// @grant        GM_openInTab

// ==/UserScript==

(function() {
  'use strict'

  const injectStyle = `
  #head_wrapper .s_btn{background: red;}
  #est_switch .est_selected{color:red}

  .fizz-myinject {
      position: fixed;
      z-index:999999;
      bottom: 30px;
      right: 30px;
      opacity: .5;
      background-color: #ffffff;
    }
    .fizz-myinject:hover{
      opacity: 1;
    }
    .fizz-myinject .main-button{
      color: #fff;
      background-color: #337ab7;
      border-color: #2e6da4;
      display: inline-block;
      padding: 6px 12px;
      margin-bottom: 0;
      font-size: 14px;
      font-weight: 400;
      line-height: 1.42857143;
      text-align: center;
      white-space: nowrap;
      vertical-align: middle;
      -ms-touch-action: manipulation;
      touch-action: manipulation;
      cursor: pointer;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      background-image: none;
      border: 1px solid transparent;
      border-radius: 4px;
    }
    .fizz-myinject .main-button:hover{
      color: #fff;
      background-color: #286090;
      border-color: #204d74;
      opacity: 1;
    }
    .fizz-myinject .fizz-wrap{
      position: relative;
    }
    .fizz-myinject .fizz-wrap .fizz-fun-ul{
      position: absolute;
      display: none;
    }
    .fizz-myinject .fizz-wrap:hover .fizz-fun-ul{
      position: absolute;
      display: block;
      bottom: 33px;
      list-style: none;
      text-align: center;
      padding: 0;
      width: 100%;
      margin: 0;
    }
    .fizz-fun-ul li.fizz-fun-li{
      list-style: none;
      text-align: center;
      width: 100%;
      padding: 8px 2px;
      margin: 0;
      border: 1px solid #ddd;
      box-sizing: border-box;
      cursor: pointer;
      background-color: #ffffff;
    }
    .fizz-fun-ul li.fizz-fun-li:hover{
      color: #fff;
      background-color: #337ab7;
      border-color: #2e6da4;
    }`
  const currentLocation = window.location.href
  const toutiaoPublishArticlePage = 'https://mp.toutiao.com/profile_v4/graphic/publish'
  // 添加样式修改
  GM_addStyle(`${injectStyle}`)

  // 功能组件
  const injectDiv = document.createElement('div')
  injectDiv.classList.add('fizz-myinject')

  injectDiv.innerHTML = `
    
  • CTT
` document.body.appendChild(injectDiv) function copyToTouTiao() { let articleHTML = $('#content_views').html() let articleTitle = $("#articleContentId").text() GM_setValue('articleHTML', articleHTML) GM_setValue('articleTitle', articleTitle) GM_openInTab(`${toutiaoPublishArticlePage}`, { active: true }) } $('#copyToTT').on('click', copyToTouTiao) // 设置文章数据 function setArticleData() { console.log(12) if (currentLocation === `${toutiaoPublishArticlePage}`) { const articleHTML = GM_getValue('articleHTML') const articleTitle = GM_getValue('articleTitle') $('.ProseMirror').html(articleHTML) $('.title-wrapper textarea').val(articleTitle) } } setTimeout(setArticleData, 3000) })()

 

CTT: CSDN文章迁移到头条自动化脚本_第1张图片

 

CTT: CSDN文章迁移到头条自动化脚本_第2张图片

你可能感兴趣的:(脚本工具)