Greasy Fork is available in English.
Twitterの共有リンクを開いたときにMisskeyの共有リンクに置換するスクリプトです。
当前为
// ==UserScript==
// @name Twitterの共有リンクをMisskeyの共有リンクに置換するスクリプト
// @namespace https://midra.me
// @version 1.0.5
// @description Twitterの共有リンクを開いたときにMisskeyの共有リンクに置換するスクリプトです。
// @author Midra
// @license MIT
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @run-at document-start
// @noframes
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// @require http://greasyfork.icu/scripts/7212-gm-config-eight-s-version/code/GM_config%20(eight's%20version).js?version=156587
// ==/UserScript==
(() => {
const configInitData = {
instance: {
label: 'インスタンス (httpsは省略)',
type: 'text',
default: 'misskey.io',
},
replace: {
label: 'オプション',
type: 'select',
default: 'afterConfirm',
options: {
auto: '自動で置換する',
afterConfirm: '置換する前に確認する',
},
},
}
GM_config.init('Twitterで共有をMisskeyで共有に置換するスクリプト 設定', configInitData)
GM_config.onload = () => {
setTimeout(() => {
alert('設定を反映させるにはページを再読み込みしてください。')
}, 200)
}
GM_registerMenuCommand('設定', GM_config.open)
// 設定取得
const config = {}
Object.keys(configInitData).forEach(v => { config[v] = GM_config.get(v) })
if (
window.location.href.startsWith('https://twitter.com/intent/tweet') ||
window.location.href.startsWith('https://twitter.com/share')
) {
const { text, url, hashtags, via } = Object.fromEntries(new URLSearchParams(window.location.search).entries())
let shareText = ''
if (text !== undefined && text !== '') {
shareText = text
}
if (url !== undefined && url !== '') {
shareText += ` ${url}`
}
if (hashtags !== undefined && hashtags !== '') {
shareText += ` #${hashtags.split(',').join(' #')}`
}
if (via !== undefined && via !== '') {
shareText += ` ?[@${via}](https://twitter.com/${via})より`
}
if (
config['replace'] === 'auto' ||
window.confirm(`指定したMisskeyのインスタンス(${config['instance']})で共有しますか?`)
) {
window.location.href = `https://${config['instance']}/share?text=${window.encodeURIComponent(shareText)}`
}
}
})()