Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

言葉 GitHub30

🌴
On vacation
Block or report user

Report or block GitHub30

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View unescapeHTML.js
function unescapeHTML(escapedHTML) {
return new DOMParser().parseFromString(escapedHTML, 'text/html').documentElement.textContent
}
View getSelectedText.js
function getSelectedText() {
const activeElement = document.activeElement
if(activeElement && ['input', 'textarea'].includes(activeElement.tagName.toLowerCase())) {
return activeElement.value.substring(activeElement.selectionStart, activeElement.selectionEnd)
} else {
return getSelection().toString()
}
}
View datamatrix.js
toCanvas(document.createElement('canvas'), {bcid:'datamatrix',text:'0123456789',scale:4,paddingwidth:4,paddingheight:4}, (e, cvs) => console.log(cvs.toDataURL('image/png')))
View printHTML.js
function printHTML(html) {
const iframe = document.createElement('iframe')
iframe.hidden=true
document.body.appendChild(iframe)
iframe.contentDocument.open()
iframe.contentDocument.write(html)
iframe.contentDocument.close()
iframe.contentWindow.print()
}
View takePhoto.js
function takePhoto(video, mimeType = 'image/jpeg') {
return new Promise(resolve => {
video.animate({opacity: [0,1]}, 300);
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
// TODO
// https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/getContext
// https://bugzilla.mozilla.org/show_bug.cgi?id=801176
canvas.getContext('2d').drawImage(video, 0, 0);
View photographer.js
function addScript(src) {
var script = document.createElement("script");
script.src = src;
document.head.appendChild(script);
}
addScript('https://stuk.github.io/jszip/dist/jszip.js')
unsafeWindow.eval(`
function dropFile(file) {
const dataTransfer = new DataTransfer();
View insertAtCaret.js
function insertAtCaret(text) {
if(!document.activeElement.setRangeText) return;
document.activeElement.setRangeText(
text,
document.activeElement.selectionStart,
document.activeElement.selectionEnd,
'end'
)
}
View fullToHalf.js
function fullToHalf(str) {
return str.replace(/[A-Za-z0-9]/g, s => String.fromCharCode(s.charCodeAt(0) - 0xFEE0));
}
View qrcode.js
// https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js
const qr = new QRCode(document.createElement('div'), {
text: '0123456789',
correctLevel : QRCode.CorrectLevel.L
})
document.body.appendChild(qr._el)
View amazondrive.user.js
// ==UserScript==
// @name Upload photos with Zip
// @version 1
// @match https://www.amazon.co.jp/clouddrive*
// @require https://raw.githubusercontent.com/vuejs/vue/v2.6.10/dist/vue.min.js
// @require https://momentjs.com/downloads/moment.min.js
// @require https://cdn.jsdelivr.net/npm/image-capture@0.4.0/lib/imagecapture.min.js
// @require https://gist.github.com/GitHub30/1b13ed6687a22385a81cf98fefdd5a13/raw/42012a345cc5cb1e4f773300e99765b644a40164/async$.js
// @grant unsafeWindow
// ==/UserScript==
You can’t perform that action at this time.