Add src/vxtwitter.user.js
This commit is contained in:
parent
95b11e1b0d
commit
077f3d91d3
1 changed files with 28 additions and 0 deletions
28
src/vxtwitter.user.js
Normal file
28
src/vxtwitter.user.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// ==UserScript==
|
||||
// @name Convert Twitter/X to FXTwitter
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 0.1
|
||||
// @description Convert copied twitter.com and x.com links to vxtwitter.com
|
||||
// @author You
|
||||
// @match *://twitter.com/*
|
||||
// @match *://x.com/*
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
document.addEventListener('copy', function(e) {
|
||||
let text = window.getSelection().toString();
|
||||
const regex = /https?:\/\/(twitter\.com|x\.com)\/[a-zA-Z0-9_\-\/]+/g;
|
||||
|
||||
if (regex.test(text)) {
|
||||
text = text.replace(regex, function(match) {
|
||||
return match.replace(/(twitter\.com|x\.com)/, 'vxtwitter.com');
|
||||
});
|
||||
text = text.split('?')
|
||||
e.clipboardData.setData('text/plain', text[0]);
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
})();
|
||||
Loading…
Add table
Reference in a new issue