Intent share URL Query string for Pinafore

Recieve "text" value and overwrite compose-box

当前为 2023-02-06 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Intent share URL Query string for Pinafore
// @name:ja        共有URLクエリ文字列 for Pinafore
// @namespace      https://greasyfork.org/ja/users/747568-yomosu
// @description    Recieve "text" value and overwrite compose-box
// @description:ja textの値を受け取り投稿ボックスを上書きする
// @version        0.1.20230201.3
// @license        CC0-1.0
// @match          *://pinafore.social/?text=*
// @grant          none
// @run-at         document-end
// ==/UserScript==

(function() {
  'use strict';
  const params = (new URL(document.location)).searchParams;
  const encoded = params.get('text');
  if (!encoded) return;

  const currentInstance = localStorage.getItem("store_currentInstance").slice(1,-1);
  if (!currentInstance) return;
  const savedData = localStorage.getItem("store_composeData");
  const tmpJson = savedData ? JSON.parse(savedData) : {};
  if (!tmpJson[currentInstance]) {
    const date = new Date();
    tmpJson[currentInstance] = {"home": {"ts" : 0}};
    tmpJson[currentInstance].home.ts = date.getTime();
  }
  const decoded = decodeURIComponent(encoded);
  if (tmpJson[currentInstance].home.text === decoded) return;
  tmpJson[currentInstance].home.text = decoded;
  const newData = JSON.stringify(tmpJson);
  localStorage.setItem("store_composeData", newData);
  location.reload();
})();