Created
March 18, 2019 15:08
-
-
Save hexium310/690b8c98448dd851693026930e8c1da2 to your computer and use it in GitHub Desktop.
TwitterCardのURLにパスも表示するやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name TwitterCardLink with path | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description TwitterCardのURLにパスも表示する | |
// @author Hexin | |
// @match https://twitter.com/* | |
// @grant GM_xmlhttpRequest | |
// @connect t.co | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Your code here... | |
const elements = document.getElementsByClassName('TwitterCard-container'); | |
for (const element of elements) { | |
const shortenedUrl = element.href; | |
const a = GM_xmlhttpRequest({ | |
method: 'GET', | |
url: shortenedUrl, | |
onload: (response) => { | |
const url = response.responseText.match(/<title>(.*)<\/title>/)[1]; | |
console.log(element.querySelector('.SummaryCard-destination')); | |
element.querySelector('.SummaryCard-destination').innerText = url || shortenedUrl; | |
}, | |
}); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment