xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
1.04k stars 87 forks source link

Help with script: Inject script on the web page #27

Closed Mitezuss closed 4 years ago

Mitezuss commented 4 years ago

Hi, im trying to add this lines:

d=document;b=d.body;o=d.createElement('scri'+'pt');o.setAttribute('src','https://translate.google.cn/translate_a/element.js?cb=googleTranslateElementInit');o.setAttribute('type','text/javascript');b.appendChild(o);v=b.insertBefore(d.createElement('div'),b.firstChild);v.id='google_translate_element';v.style.display='none';p=d.createElement('scri'+'pt');p.text='function googleTranslateElementInit(){new google.translate.TranslateElement({pageLanguage:\"\"},\"google_translate_element\");}';p.setAttribute('type','text/javascript');b.appendChild(p);

To a script, for run injected on the web page. But i do not know how do that... need use loadURI, but not load...

That lines inject google translate on the page (can test adding to a bookmark and pressing then the google translate appear... so, i wanna do a script (in context menu)) (Note: need add javascript:{ LINES }void 0

Appreciate your help =)