• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ttrace/oxpecker: adding translation button on Mastodon with bookmarklet

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ttrace/oxpecker

开源软件地址(OpenSource Url):

https://github.com/ttrace/oxpecker

开源编程语言(OpenSource Language):

JavaScript 81.6%

开源软件介绍(OpenSource Introduction):

oxpecker

oxpecker adds translation button on Mastodon with bookmarklet.

demo for Javascript Birthday!

followingcode runs only developer page. I boost father of Javascript, Brendan Eich's toots today (15th April).

copy following code and paste on location of your browser.

javascript:(function()%7B(function(c)%7Bvar%20b=%7B%7D;function%20a(e)%7Bif(b%5Be%5D)%7Breturn%20b%5Be%5D.exports%7Dvar%20d=b%5Be%5D=%7Bi:e,l:false,exports:%7B%7D%7D;c%5Be%5D.call(d.exports,d,d.exports,a);d.l=true;return%20d.exports%7Da.m=c;a.c=b;a.i=function(a)%7Breturn%20a%7D;a.d=function(b,c,d)%7Bif(!a.o(b,c))%7BObject.defineProperty(b,c,%7Bconfigurable:false,enumerable:true,get:d%7D)%7D%7D;a.n=function(b)%7Bvar%20c=b%26%26b.__esModule%3Ffunction%20a()%7Breturn%20b%5B'default'%5D%7D:function%20a()%7Breturn%20b%7D;a.d(c,'a',c);return%20c%7D;a.o=function(a,b)%7Breturn%20Object.prototype.hasOwnProperty.call(a,b)%7D;a.p='';return%20a(a.s=2)%7D(%5Bfunction(a,b)%7Ba.exports=%7Bapi_key:'AIzaSyCzYjoqZrHUUUc4A9IKcZdbnaqecDB-9ak',ox_target_language:'ja'%7D%7D,function(a,b)%7Ba.exports=function()%7Bvar%20a=document.createElement('A');a.innerHTML='文/A';a.style.cssText='background-color:%23606984;color:%23393f4f;font-weight:bold;cursor:pointer;line-height:1.25em;padding:0.3em;border-radius:0.5em;margin-left:%2018px;%20float:%20right;%20position:%20relative;%20top:%20-24px;font-size:0.75em';return%20a%7D%7D,function(i,j,d)%7Bvar%20a=d(0);var%20c='https://translation.googleapis.com/language/translate/v2%3Fkey='+a.api_key;var%20g=a.ox_target_language;var%20h=(window.navigator.languages%26%26window.navigator.languages%5B0%5D).split('-')%5B0%5D;var%20b=$('.status__content').not($('.ox-flagged')).not($('.status.muted%20.status__content'));var%20f=d(1);var%20e=f();b.each(function(j)%7Bvar%20a=b%5Bj%5D;var%20h=a.textContent;var%20k='init';var%20f=e.cloneNode(true);var%20d=document.createElement('DIV');d.id='translation_'+Math.round(Math.random()*1e3);var%20i=d.id;a.appendChild(d);a.classList.add('ox-flagged');a.parentNode.appendChild(f);f.addEventListener('click',function()%7Bconsole.log('started');$.ajax(%7Btype:'GET',dataType:'jsonp',url:c,data:%7Bq:h,target:g%7D%7D).then(function(a)%7Bconsole.log(a.data.translations%5B0%5D.translatedText);$('%23'+i).after(a.data.translations%5B0%5D.translatedText)%7D,function()%7Bconsole.log('error')%7D)%7D,false)%7D)%7D%5D))%7D())

Build

Duplicate oxpecker.config.sample.js as oxpecker.config.js and write Google Translation Key.

$ webpack && bookmarkletter bookmark.js

and copy output on your browser.

Requirement

known issues

oxpecker lacks many feature, current code is just only for working confirmation. Developer is going to implement following features.

  • language switcher and keeping settings
  • auto adding translation button
  • supporting another translation API (Bing and Yandex)
  • develop easy implemantation on Mastodon instance without bookmarklet.

License

oxpecker are made available under the terms of the GNU Affero General Public License (GNU AGPLv3) with respecting Mastodon , since 17:00 JST 16th,May 2017.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap