Guest User

Tampermonkey Script to "pop out" toot composition for Mastodon

a guest
Sep 4th, 2020
161
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Koyu.space embiggener
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://koyu.space/*
  8. // @grant        none
  9. // ==/UserScript==
  10. (function() {
  11.     'use strict';
  12.  
  13.     // Your code here...
  14.     window.tm_embiggen = function() {
  15.         document.getElementById('tm_embiggen_box_container').style.display = 'block';
  16.         document.getElementById('tm_embiggen_box').value = document.getElementsByClassName('autosuggest-textarea__textarea')[0].value;
  17.     };
  18.  
  19.     window.tm_ensmallen = function() {
  20.         var native_textarea = document.getElementsByClassName('autosuggest-textarea__textarea')[0];
  21.         var last_value = native_textarea.value
  22.  
  23.         native_textarea.value = document.getElementById('tm_embiggen_box').value;
  24.  
  25.         var tracker = native_textarea._valueTracker;
  26.         if (tracker) {
  27.             tracker.setValue(last_value);
  28.         }
  29.         native_textarea.dispatchEvent(new Event('input', { target: native_textarea, bubbles: true }));
  30.  
  31.         document.getElementById('tm_embiggen_box_container').style.display = 'none';
  32.     };
  33.  
  34.     var div = document.getElementsByClassName('composer--options');
  35.     if (div.length != 1) return;
  36.     div = div[0];
  37.  
  38.     var big_button = document.createElement('button');
  39.     big_button.classList = ['text-icon-button'];
  40.     big_button.style = 'line-height: 27px; width: 23.1429px;';
  41.     big_button.addEventListener('click', window.tm_embiggen);
  42.     big_button.innerHTML = 'Big';
  43.  
  44.     var modal = document.createElement('div');
  45.     modal.id = "tm_embiggen_box_container";
  46.     modal.style = 'display: none; position: absolute; width: 40%; box-sizing: border-box; top: 25%; left: 30%; height: 450px; padding: 20px; background-color: black; border: 2px solid lightslategray; border-radius: 20px;';
  47.  
  48.     var text = document.createElement('textarea');
  49.     text.id = 'tm_embiggen_box';
  50.     text.style = 'width: 100%; height: 80%; box-sizing: border-box; padding: 10px; font-family: sans-serif; font-size: 16px; border: 0; border-radius: 6px; outline: none !important; resize: none;';
  51.  
  52.     var button = document.createElement('button');
  53.     button.addEventListener('click', window.tm_ensmallen);
  54.     button.style = 'margin-top: 10px; font-size: 16px; border: 0; border-radius: 5px; padding: 8px 25px; background-color: mediumseagreen; color: white;';
  55.     button.innerHTML = 'Close';
  56.  
  57.     div.appendChild(big_button);
  58.     modal.appendChild(text);
  59.     modal.appendChild(button);
  60.     document.body.appendChild(modal);
  61. })();
  62.  
RAW Paste Data