reflector-extn-ws-client
Installation
reflector-extn-ws-client |
Firefox |
https://root-interface.se/dl/reflector-extn-ws-client/3427ab4fda784e49930b-0.0.26.xpi |
|---|
Usage
DEMO
// ==UserScript==
// @name TwitterX-2PhW
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Modify the text content of tweetText to a clickable link
// @author You
// @match *://*.twitter.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function merge(json) {
const dt_Msg = new Date();
let json_msg = {
id: dt_Msg.toISOString(), //uuidv4(),
referer: null,
dt: dt_Msg.toISOString(),
}
for (var key of Object.keys(json)) {
json_msg[key] = json[key];
}
return json_msg;
}
const bc= new BroadcastChannel('IPSME');
// The separate function to handle the click
function handleClick(event) {
event.preventDefault();
const json= merge({
"2PhW": "0.6",
"warp" : {
"hyperport": "secondlife://Ahern/128/128",
"ttl_msec": 20000
}
});
json.referer= ["twitter.com", window.location.href];
console.log('Twitter-2PhW: publish', json);
bc.postMessage(JSON.stringify(json));
}
function modifyText() {
Array.from(document.querySelectorAll("article div[data-testid='tweetText']"))
.forEach(div => {
let span = div.querySelector('span');
if (span && !span.querySelector('a') && span.textContent.startsWith("2PhW+secondlife://")) {
let originalText = span.textContent;
let link = document.createElement('a');
link.href = "#";
link.textContent = originalText;
link.addEventListener('click', handleClick);
span.innerHTML = '';
span.appendChild(link);
}
});
}
// Run the function initially
modifyText();
// Set up the MutationObserver to observe changes in the DOM
const observer = new MutationObserver(() => {
modifyText();
});
observer.observe(document.body, {
childList: true,
subtree: true
});
})();