Facebook用户事件

时间:2013-07-17 18:42:10

标签: javascript facebook userscripts

此脚本仅在我移动鼠标时有效。如何安排它始终保持激活状态?

// ==UserScript==
// @name       Corrige Script
// @namespace  www.Thyago.com/corrigebug
// @version    0.1
// @description  Corrigir o bug que não permitia marcar codigos
// @include     https://*.facebook.com/*
// @include     https://facebook.com/*
// @include     http://*.facebook.com/*
// @include     http://facebook.com/*
// @author      Thyago RIbeiro (www.fb.com/thyagosr)
// ==/UserScript==

function att(){
var c = document.getElementsByName('xhpc_message_text')[0];
document.getElementsByName('xhpc_message')[0].value = c.value;
console.log(document.getElementsByName('xhpc_message')[0].value);
}

function att2(){
document.getElementsByName('message')[0].value = document.getElementsByName('message_text')[0].value;
}

function corrige(){
if(document.getElementsByName("xhpc_message_text")[0]!== undefined){
     var varDivTexto = document.getElementsByName("xhpc_message_text")[0];
     varDivTexto.addEventListener("keypress",att, false);

var c = document.getElementsByName('xhpc_message_text')[0];
document.getElementsByName('xhpc_message')[0].value = c.value;
}

if(document.getElementsByName('message')[0] !== undefined){
     var varDivTexto = document.getElementsByName('message')[0];
     varDivTexto.addEventListener("keypress",att2, false);
document.getElementsByName('message')[0].value = document.getElementsByName('message_text')[0].value;
}

}

document.addEventListener ("mousemove", corrige, true);

1 个答案:

答案 0 :(得分:0)

[edit] (固定代码)

您的问题不明确,我不确切地知道您想要什么,请尝试:

//document.addEventListener ("mousemove", corrige, true); --line commented out that only works with the event "timeout"

function autoCorrige(){
  //call the function "correct" - chama a função "corrige"
  corrige();

  //Waiting 1 second to run the code again - 1 segundo de espera para executar novamente o código
  setTimeout(autoCorrige,1000);
}

autoCorrige();//starts the automatic event - inicia o evento automático

[如何提出好问题的提示]

如何使用 SO (stackoverflow):

首先要提出一个清晰易懂的问题:

https://stackoverflow.com/help/asking

当您针对特定用户定位彗星时,请使用“@ USERNAME”

  

pt-br / pt: Como usar o SO stackoverflow ):

     

Primeiramente para se ter uma pergunta claraecompreensívelvocêdeve   LER:

     

https://stackoverflow.com/help/asking

     

quandovocêestiverdirecionandoucometáriosraumusuário   especifico使用@NOMEDOUSUARIO