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 = `
    <div class="fizz-wrap">
      <ul class="fizz-fun-ul">
        <li class="fizz-fun-li" id="copyToTT">CTT</li>
      </ul>
      <button class="main-button">扩展功能</button>
    </div>
  `
  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)
 
})()```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值