Skip to content

Instantly share code, notes, and snippets.

@ninja33
ninja33 / wordspace
Created April 27, 2017 07:21
add space between words of shanbay.com news article.
// @name Shanbay News Word Space
// @namespace https://github.com/ninja33
// @version 0.1
// @description Add space between words of Shanbay news article.
// @author Ninja Huang
// @match https://www.shanbay.com/news/articles/*
// @grant none
// ==/UserScript==
(function() {
@ninja33
ninja33 / jsonp.js
Created January 18, 2018 08:45
a simple and pure javascript jsonp function
function loadJsonp(url, callback) {
var callbackName = 'jsonp_callback_' + Math.round(100000 * Math.random());
window[callbackName] = function (data) {
delete window[callbackName];
document.body.removeChild(script);
callback(data);
};
var script = document.createElement('script');
script.src = url + (url.indexOf('?') >= 0 ? '&' : '?') + 'callback=' + callbackName;
@ninja33
ninja33 / youdao_trans.js
Created March 7, 2019 05:42
get Youdao word translation in one statement
var word = 'test';
fetch('https://dict.youdao.com/w/'+word).then(r=>r.text()).then(html=>{console.log((new DOMParser()).parseFromString(html, 'text/html').querySelector('#phrsListTab .trans-container').textContent)})
@ninja33
ninja33 / enpl_Cambridge.js
Last active October 14, 2020 06:48
Cambridge English->Polish dictionary script for ODH
/* global api */
class enpl_Cambridge {
constructor(options) {
this.options = options;
this.maxexample = 2;
this.word = '';
}
async displayName() {
return 'Cambridge EN->PL Dictionary';
@ninja33
ninja33 / encn_Cambridge_tc.js
Last active July 16, 2019 15:49
ODH(Online Dictionary Helper) user defined script for Chinese-English (Traditional Chinese)
/* global api */
class encn_Cambridge_tc {
constructor(options) {
this.options = options;
this.maxexample = 2;
this.word = '';
}
async displayName() {
let locale = await api.locale();
@ninja33
ninja33 / esen_Spanishdict.js
Created August 10, 2019 03:33
Spanish to English dictionary (spanishdict.com) script for Chrome extension "Online Dictionary Helper"
/* global api */
class esen_Spanishdict {
constructor(options) {
this.options = options;
this.maxexample = 2;
this.word = '';
}
async displayName() {
let locale = await api.locale();
/* global api */
class decn_Eudict {
constructor(options) {
this.options = options;
this.maxexample = 2;
this.word = '';
}
async displayName() {
let locale = await api.locale();
/* global api */
class encn_TestDict {
constructor(options) {
this.options = options;
this.maxexample = 2;
this.word = '';
}
async displayName() {
let locale = await api.locale();