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();
/* global api */
class finnZhDictionary {
constructor(options) {
this.apiUrl = "https://www.sanakirja.fi/api/search/api/sk/search";
this.headers = {
"Accept": "application/json",
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6dHJ1ZSwiaWF0IjoxNzIyNzcyODY4LCJqdGkiOiIzNjcxYmFlYS05M2Y3LTRiMDItOGEzZi0yYjg2N2Q0OGY3ZDkiLCJ0eXBlIjoiYWNjZXNzIiwiaWRlbnRpdHkiOnsidXNlcl9pZCI6IjViZWRlNjhmLTIxZmYtNDE3Ny1iZDBiLWU0YjU5NWNhM2I2NSIsImNsaWVudCI6IkdVNzdSeTRMWThhOEc3NElCZzAzQm5WMDhBNTQ2azY1IiwiY2xpZW50X25hbWUiOiJzYW5ha2lyamEifSwibmJmIjoxNzIyNzcyODY4LCJleHAiOjE3MjI3NzY0NjgsInVzZXJfY2xhaW1zIjp7Imhhc1ByZW1pdW1Db250ZW50Ijp0cnVlLCJzdGF0c1VzZXJUeXBlIjoidHJpYWwifX0.ZJUSoindRSjoxz-x9hhBaKVxBEsFS2K4qjooq0pBjcQ",
"Content-Type": "application/json",
"Cookie": "xxoo-tmp=en-US",
"Ngsw-Bypass": "true",