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

举报
拿我格子衫来 发表于 2022/03/17 22:40:08 2022/03/17
【摘要】 油猴脚本,如果有用请点赞收藏,关注此专栏。谢谢。 // ==UserScript==// @name CTT// @namespace https://fizzz.blog.csdn.net/// @version 0.1// @description try to take over the wor...

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


  
  1. // ==UserScript==
  2. // @name CTT
  3. // @namespace https://fizzz.blog.csdn.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author Fizz
  7. // @match https://**.csdn.net/**/**
  8. // @match https://mp.toutiao.com/profile_v4/graphic/publish
  9. // @require https://lib.baomitu.com/jquery/3.5.0/jquery.js
  10. // @require https://cdn.staticfile.org/html2canvas/0.5.0-beta4/html2canvas.min.js
  11. // @run-at document-end
  12. // @grant GM_addStyle
  13. // @grant GM_getValue
  14. // @grant GM_setValue
  15. // @grant GM_addValueChangeListener
  16. // @grant GM_openInTab
  17. // ==/UserScript==
  18. (function() {
  19. 'use strict'
  20. const injectStyle = `
  21. #head_wrapper .s_btn{background: red;}
  22. #est_switch .est_selected{color:red}
  23. .fizz-myinject {
  24. position: fixed;
  25. z-index:999999;
  26. bottom: 30px;
  27. right: 30px;
  28. opacity: .5;
  29. background-color: #ffffff;
  30. }
  31. .fizz-myinject:hover{
  32. opacity: 1;
  33. }
  34. .fizz-myinject .main-button{
  35. color: #fff;
  36. background-color: #337ab7;
  37. border-color: #2e6da4;
  38. display: inline-block;
  39. padding: 6px 12px;
  40. margin-bottom: 0;
  41. font-size: 14px;
  42. font-weight: 400;
  43. line-height: 1.42857143;
  44. text-align: center;
  45. white-space: nowrap;
  46. vertical-align: middle;
  47. -ms-touch-action: manipulation;
  48. touch-action: manipulation;
  49. cursor: pointer;
  50. -webkit-user-select: none;
  51. -moz-user-select: none;
  52. -ms-user-select: none;
  53. user-select: none;
  54. background-image: none;
  55. border: 1px solid transparent;
  56. border-radius: 4px;
  57. }
  58. .fizz-myinject .main-button:hover{
  59. color: #fff;
  60. background-color: #286090;
  61. border-color: #204d74;
  62. opacity: 1;
  63. }
  64. .fizz-myinject .fizz-wrap{
  65. position: relative;
  66. }
  67. .fizz-myinject .fizz-wrap .fizz-fun-ul{
  68. position: absolute;
  69. display: none;
  70. }
  71. .fizz-myinject .fizz-wrap:hover .fizz-fun-ul{
  72. position: absolute;
  73. display: block;
  74. bottom: 33px;
  75. list-style: none;
  76. text-align: center;
  77. padding: 0;
  78. width: 100%;
  79. margin: 0;
  80. }
  81. .fizz-fun-ul li.fizz-fun-li{
  82. list-style: none;
  83. text-align: center;
  84. width: 100%;
  85. padding: 8px 2px;
  86. margin: 0;
  87. border: 1px solid #ddd;
  88. box-sizing: border-box;
  89. cursor: pointer;
  90. background-color: #ffffff;
  91. }
  92. .fizz-fun-ul li.fizz-fun-li:hover{
  93. color: #fff;
  94. background-color: #337ab7;
  95. border-color: #2e6da4;
  96. }`
  97. const currentLocation = window.location.href
  98. const toutiaoPublishArticlePage = 'https://mp.toutiao.com/profile_v4/graphic/publish'
  99. // 添加样式修改
  100. GM_addStyle(`${injectStyle}`)
  101. // 功能组件
  102. const injectDiv = document.createElement('div')
  103. injectDiv.classList.add('fizz-myinject')
  104. injectDiv.innerHTML = `
  105. <div class="fizz-wrap">
  106. <ul class="fizz-fun-ul">
  107. <li class="fizz-fun-li" id="copyToTT">CTT</li>
  108. </ul>
  109. <button class="main-button">扩展功能</button>
  110. </div>
  111. `
  112. document.body.appendChild(injectDiv)
  113. function copyToTouTiao() {
  114. let articleHTML = $('#content_views').html()
  115. let articleTitle = $("#articleContentId").text()
  116. GM_setValue('articleHTML', articleHTML)
  117. GM_setValue('articleTitle', articleTitle)
  118. GM_openInTab(`${toutiaoPublishArticlePage}`, { active: true })
  119. }
  120. $('#copyToTT').on('click', copyToTouTiao)
  121. // 设置文章数据
  122. function setArticleData() {
  123. console.log(12)
  124. if (currentLocation === `${toutiaoPublishArticlePage}`) {
  125. const articleHTML = GM_getValue('articleHTML')
  126. const articleTitle = GM_getValue('articleTitle')
  127. $('.ProseMirror').html(articleHTML)
  128. $('.title-wrapper textarea').val(articleTitle)
  129. }
  130. }
  131. setTimeout(setArticleData, 3000)
  132. })()

 

 

文章来源: fizzz.blog.csdn.net,作者:拿我格子衫来,版权归原作者所有,如需转载,请联系作者。

原文链接:fizzz.blog.csdn.net/article/details/108475766

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。