Skip to content

Instantly share code, notes, and snippets.

@c18t
Last active March 20, 2019 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c18t/efb48e70b5b6a3ecc924b9e6bf0ca90a to your computer and use it in GitHub Desktop.
Save c18t/efb48e70b5b6a3ecc924b9e6bf0ca90a to your computer and use it in GitHub Desktop.
show `Share Tumblr` button on nicovideo.jp
// ==UserScript==
// @name NicoVideo to Tumblr (nicovideo)
// @namespace https://u.chimata.org/
// @version 0.1
// @description show `Share Tumblr` button on nicovideo.jp
// @author You
// @match https://*.nicovideo.jp/watch/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var timerId; timerId = setInterval(function() {
var button = document.querySelector('button.SharePanelVisibleButton');
if (button) {
clearInterval(timerId);
button.addEventListener('click', showTumblrButton, false);
}
}, 100);
function showTumblrButton() {
setTimeout(function() {
var t = document.querySelector('textarea.SharePanelContainer-textarea');
if (t) {
var div = document.querySelector('.SharePanelContainer-radioGroup');
var url = 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=https://www.nicovideo.jp/'
+ '&posttype=video&caption=' + t.value.match(/<a[^>]+>(.*)<\/a>/)[1];
var tumblrButton = document.createElement('button');
tumblrButton.className = 'tumblr-button';
tumblrButton.innerText = 'Share Tumblr';
tumblrButton.style.display = 'block';
tumblrButton.style.margin = '10px auto';
tumblrButton.style.padding = '8px';
tumblrButton.style.fontSize = '0.8rem';
tumblrButton.style.color = '#fff';
tumblrButton.style.backgroundColor = '#001935';
tumblrButton.style.border = '1px solid #ccc';
tumblrButton.style.borderRadius = '4px';
tumblrButton.addEventListener('click', function() {
t.focus();
document.execCommand('copy');
t.blur();
window.open(url);
}, false);
div.appendChild(tumblrButton);
}
}, 100);
}
})();
// ==UserScript==
// @name NicoVideo to Tumblr (tumblr)
// @namespace https://u.chimata.org/
// @version 0.1
// @description show `Share Tumblr` button on nicovideo.jp
// @author You
// @match https://www.tumblr.com/widgets/share/tool?canonicalUrl=https://www.nicovideo.jp/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var timerId; timerId = setInterval(function() {
var button = document.querySelector('.media-url-button');
if (button) {
clearInterval(timerId);
button.addEventListener('click', function() {
setTimeout(function() {
document.querySelector('.media-url .editor-plaintext span').focus()
console.log('auto paste embed code:', document.execCommand('paste'));
}, 500);
});
button.click();
}
}, 100);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment