Intent share URL Query string for Pinafore

Recieve "text" value and overwrite compose-box

Stan na 06-02-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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();
})();