CTT: CSDN文章迁移到头条自动化脚本
【摘要】
油猴脚本,如果有用请点赞收藏,关注此专栏。谢谢。
// ==UserScript==// @name CTT// @namespace https://fizzz.blog.csdn.net/// @version 0.1// @description try to take over the wor...
油猴脚本,如果有用请点赞收藏,关注此专栏。谢谢。
-
// ==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)
-
-
})()
文章来源: fizzz.blog.csdn.net,作者:拿我格子衫来,版权归原作者所有,如需转载,请联系作者。
原文链接:fizzz.blog.csdn.net/article/details/108475766
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)