Greasy Fork

Greasy Fork is available in English.

置顶每日乱弹

May the Tweets Daily always on the Top without this script.

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         置顶每日乱弹
// @namespace    https://hi.cellmean.com/
// @version      0.1
// @description  May the Tweets Daily always on the Top without this script.
// @author       Falcon
// @match        https://www.oschina.net/tweets
// @match        https://my.oschina.net/*
// @icon         https://static.oschina.net/new-osc/img/favicon.ico
// @run-at       document-end
// @grant        none

// ==/UserScript==

(function() {
    'use strict';
    if(document.querySelector('.web-tweet-common') || document.querySelector('.tweet-detail-page') ){


        fetch('https://wwwosc.cellmean.com/daily-tweets?scope=entity&p=1&type=ajax',{
            method: 'GET',
            headers:{
                "Content-Type": "text/html"
            },
            mode: 'cors'
        })
        .then(res=> {
            if(res.ok) { // 此处加入响应状态码判断
                return res.text()
            }else{
                console.log('Fail:', JSON.stringify(res))
            }

        })
        .then(html=>{
            const parser=new DOMParser()
            const htmlDoc=parser.parseFromString(html, "text/html")
            const tweetItem = htmlDoc.querySelector('.tweet-item')
            const feed = document.querySelector('.sidebar .feed')
            feed.prepend(tweetItem)

        })
        .catch(error=>console.log('Error:',error))
    }
})();