2016-09-30 5 views
-1

매번 동일한 패키지를 사용하는 대신 다운로드 패키지의 제목을 변경할 수 있도록이 북마크릿 (다운로드 관리자 인 pyLoad)을 수정하려고합니다. 나는 북마크에 팝업을 추가하는 것이 가능하다는 것을 알고 있지만,이 요청을 수정하는 방법을 모른다.자바 스크립트 북마크 렛 - 팝업 제목을 추가하는 방법은 무엇입니까?

여기에 코드

javascript:function filtreAuto(){var e=[];e["aucun"]="aucun";e["A_Site"]="http://A_site.com/";return e}function bookmarklet(){var e=document.createElement("div");url=filterUrl();e.innerHTML='<h1>URL</h1><input type="checkbox" name="checkboxUrl" id="'+url+'" value="checkbox0"><label for="checkbox0"><a href="'+url+'">'+url+"</a></label><br />";var t=document.createElement("div");var n=document.createElement("h2");n.setAttribute("id","Filtrer les liens par mots clé:");t.appendChild(n);var r=document.createElement("input");r.setAttribute("id","searchInput");r.setAttribute("name","searchInput");r.setAttribute("type","text");r.setAttribute("placeholder","Filtre personnaliser...");t.appendChild(r);t.innerHTML=t.innerHTML+" ou Filtre Auto: ";var i=document.createElement("select");i.setAttribute("id","searchAuto");i.onchange=function(){win.document.getElementById("searchInput").value=""};filtre=filtreAuto();for(var s in filtre){var o=document.createElement("option");o.value=filtre[s];o.text=s;i.appendChild(o)}t.appendChild(i);var u=document.createElement("button");u.onclick=function(){findLinks()};u.innerHTML="search";t.appendChild(u);var a=document.createElement("button");a.setAttribute("id","cocher");a.onclick=function(){linksCheck()};a.innerHTML="Tout cocher";t.appendChild(a);var f=document.createElement("button");f.setAttribute("id","pyLoad");f.onclick=function(){toPyload()};f.innerHTML="Envoi à pyLoad";t.appendChild(f);var l=document.createElement("div");l.setAttribute("id","divList");win.document.body.appendChild(e);win.document.body.appendChild(t);win.document.body.appendChild(l);findLinks()}function linksCheck(){var e=win.document.getElementById("cocher");e.innerHTML=="Tout cocher"?e.innerHTML="Tout décocher":e.innerHTML="Tout cocher";var t=win.document.getElementById("conteneur").firstChild;while(t!=null){if(t.getAttribute("type")=="checkbox"){test=e.innerHTML=="Tout cocher"?false:true;win.document.getElementsByName("checkboxUrl")[0].checked=test;win.document.getElementById(t.getAttribute("id")).checked=test}t=t.nextSibling}return false}function filterUrl(){url=winx.document.URL;if(url.lastIndexOf("youtube")!=-1){g=new RegExp("v=.{11}");idVideo=g.exec(url);urlYoutube="http://www.youtube.com/watch?"+idVideo;url=urlYoutube}return url}function findLinks(){win.document.getElementById("cocher").innerHTML="Tout cocher";var e=win.document.getElementById("searchAuto").value;var t=win.document.getElementById("searchInput").value;title="<h2>Tous les liens "+t+":</h2>";if(!t){if(e=="aucun"){t="";title="<h2>Pas de filtre:</h2>"}else{t=e;title="<h2>Filtre des liens :"+t+"</h2>"}}else{win.document.getElementById("searchAuto").value="aucun"}texte=title+'<div id="conteneur">';for(var n=0;n<list_Links.length;n++){list_Links[n].lastIndexOf(t)!=-1?texte+='<input type="checkbox" name="checkbox'+n+'" id="'+list_Links[n]+'" value="checkbox'+n+'"><label for="checkbox'+n+'"><a href="'+list_Links[n]+'">'+list_Links[n]+"</a></label><br />":""}var r=win.document.getElementById("divList");r.innerHTML=texte+"</div>"}function createListLinks(){list_Links=[];for(var e=winx.document.links.length-1,t;t=winx.document.links[e];e--){if(!t.href.match(/^(javascript:|data:)/)){lien=t.href;list_Links.push(lien)}}return list_Links}function toPyload(){list_Pyload=[];var e=win.document.getElementsByName("checkboxUrl")[0];e.checked?list_Pyload.push(e.id):"";var t=win.document.getElementById("conteneur").firstChild;while(t!=null){if(t.getAttribute("type")=="checkbox"){t.checked?list_Pyload.push(t.getAttribute("id")):""}t=t.nextSibling}if(list_Pyload==""){return false}jLinks=JSON.stringify(list_Pyload);urlx='http://localhost:8000/api/addPackage?name="download"&links='+jLinks;winz=window.open(urlx,"","resizable=no, location=no, width=100, height=100, menubar=no, status=no, scrollbars=no, menubar=no");setTimeout("winz.close()",50);win.close()}winx=window;win=window.open("","_blank","width=800,height=600,scrollbars,resizable,menubar");list_Links=createListLinks();bookmarklet() 

의이 팝업 조치를 추가 pyLoad

urlx='http://localhost:8000/api/addPackage?name="download"&links= 

난 할 노력하고있어 것은 URL을 전송하는 문자열입니다 볼 수 있듯이 그래서 언제든지 변경할 수 있습니다. addPackage 이름이지만 브라우저에서 사용할 수 있도록 자바 스크립트로이 요청을 추가하는 방법 (및 가능한 경우)을 알 수 없습니다.

편집 : 나는이

javascript: 
(function() { 
    var val= prompt("Enter #",""); 
    if (val) 
     location="http://www.test.com/"+escape(val)+"/html/stuff"; 
})() 

하지만 어떻게 간단한 URL 대신 자바 스크립트 북마크를 삽입 발견?

+0

'addPackage'대신 추가 할 폴더를 지정하는 프롬프트 상자를 추가 할 수 있습니다. 그런 다음이 값을 addPackage 대신 urlx에 전달하면됩니다. –

+0

늦게 답변을 드려 죄송합니다. 메일 알림을 보지 못했습니다. 간단한 예를 들어 도와 주시겠습니까? – DylanDog

답변

1

당신이 찾은 것은 초기 요청에서 필요한 것입니다. 이 값을 표시

(function() { 
    var val= prompt("Enter #",""); 
    if (val) 
     bookmarklet(val); 
})() 

그런 다음 당신은 북마크 코드를 업데이트해야합니다 : 당신은 그 다음 필요에 따라 URL을 변경할 수있는 문는 북마크 기능으로 입력 값을 밀어 경우 를 업데이트해야

urlx = 'http://localhost:8000/api/'+val+'?name="download"&links=' + jLinks; 

: 코드에서() 북마크하기 위해 다른 호출을 제거해야합니다.

+0

감사합니다. 그래서 첫 번째 북마크 릿을 실행 한 다음 두 번째 북마크를 실행해야합니까, 아니면 잘못 되었습니까? – DylanDog

관련 문제