מדיה ויקי:Common.js/externalsmaker.js
הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.
- פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
- גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
- אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
- אופרה: ללחוץ על Ctrl-F5.
function wikiit() {
function dateFormat(dateArr) { if (dateArr instanceof Array) { if (dateArr.length != 3) return ;
m = dateArr[1]; d = dateArr[0]; y = dateArr[2]
return "תבנית:תע+"; } return jQuery.trim(dateArr); }
function engDateParse(engDate) { var m = ["January" , "February" , "March" , "April", "May", "June", "July", "August", "September", "October","November", "December"]; engDate = engDate.match(/(\w+) (\d+), (\d+)/); return [engDate[2], (m.indexOf(engDate[1]) + 1) , engDate[3] ]; }
function match (str, expr){str = str?str.match(expr):str; return (str&&str.length>1)?str[1]:;}
function getParameterByName(name) { /* http://james.padolsey.com/javascript/bujs-1-getparameterbyname/ */ var match = RegExp('[?&]' + name + '=([^&]*)') .exec(window.location.href); return match && decodeURIComponent(match[1].replace(/\+/gi, ' ')); }
var data = [
{
hostname: 'old2.ih.chabad.info', hrefmatch:/audio\.php/, params: [ { str: 'קישור חבד אינפו שמע' }, { urlparam: 'id' }, { func: function(){
var oReq = new XMLHttpRequest(); oReq.open("get", $("param[name=movie]").val().match(/ram=(.*?)$/)[1], false); oReq.overrideMimeType("text/plain; charset=x-user-defined"); oReq.send(); s = oReq.response.split("&")[3].split("=")[1]; z = "" for(var i=0;i<s.length;i++) { q = s.charCodeAt(i); if(q > 0xff) { y = (q&0xff); z += String.fromCharCode(y+1264) } else z += s.charAt(i); } q = z.split(">").join("+|+"); return q;
}} ] },
{
hostname: 'video.chabad.info', params: [ { str: 'קישור חבד וידפו' }, { urlparam: 'id' }, { telem: '.art_title' } ] },
{
hostname: 'old2.ih.chabad.info', hrefmatch:/video/, params: [ { str: '2קישור חבד וידפו' }, { urlparam: 'id' }, { telem: '.art_title' } ] },
{
hostname: 'old2.ih.chabad.info', hrefmatch:/#!g=1&tag=*/, params: [ { str: 'תגית באינפו הישן' }, { telem: 'div.news_action_desc',remove:["תגית: "] } ] },
{
hostname: 'chabad.info', hrefmatch:/tag/, params: [ { str: 'קישור לתג באינפו' }, { telem: 'h2:first',remove:["Posts related to the tag '","': "] } ] },
{
hostname: 'old2.ih.chabad.info',hrefmatch:/#!g=1&url=article*/,
params: [
{ str: 'קישור חבד אינפו' },
{ urlparam: 'id' },
{ telem: 'div.art_title' },
{ telem: 'div.art_author' },
{ telem: 'div.art_time_id', match:/(\d+\.\d+\.\d+)/, split:'.', func:dateFormat}
]
},
{ hostname: 'www.chabad.co.il', params: [ { str: 'קישור חבד בישראל' }, { urlparam: 'topic' }, { urlparam: 'article' }, { telem: 'div.art_title' }, { telem: 'div.art_author' }, { telem: 'div.art_date', match:/(\d+\.\d+\.\d+)/, split:'.', func:dateFormat } ] }, { hostname: 'hageula.com', params: [ { str: 'קישור הגאולה' }, { str: location.href, match: /hageula.com\/[^/]+\/([^/]+)\/\d+\.html/ }, { str: location.href, match: /hageula.com\/[^/]+\/[^/]+\/(\d+)\.html/ }, { telem: 'h1:first' }, { elem: ['a[href^="/author"]', 'parent', 'text'], remove:"מערכת האתר"}, { telem: 'table.Aborder tr:first td:last div', split:'.', func:dateFormat}, { str: location.href, match: /hageula.com\/([^/]+)\/[^/]+\/\d+\.html/, defvalue:'news'} ] }, { hostname: 'col.org.il', params: [ { str: 'קישור חבד און ליין' }, [
{ urlparam: 'artID'}, { str:location.href, match:/_(\d+)\.html?$/} ],
{ telem: 'table:eq(6) div:first' }, { str: }, //author { telem: 'table:eq(6) div:eq(1)', match:/\(יום .+, (.*?)\)/} ] }, { hostname: 'shturem.net', params: [ { str: 'קישור שטורעם' }, { urlparam:'id' }, { urlparam:'section' }, { telem: '.artTitle' }, { telem: '.artReporter' }, { telem: '.artDate' } ] }, { hostname: 'www.chabad.org.il', hrefmatch:/Magazines/, params: [ { str: 'קישור התקשרות צאח' }, { urlparam: 'CategoryID' }, { urlparam: 'ArticleID' }, { telem: "a.navigationTab:contains('התקשרות'):last" , match:/(\d+)/ }, { telem: ".CategoryTitle" }, { telem: '.bodyinsmall' , match:/^מאת:?(.*?)\n/m }, ] }, {
hostname: "www.scribd.com", params: [ { str: 'קישור בית משיח'}, { str: location.href, match: /doc\/(\d+)\//}, { func: function(){return $(".pager input").val();} }, { telem: "h1.book_title"}, { func: function(){return prompt("כותרת כתבה")}}, { func: function(){return prompt("שם כתב")}} ]
}, {
hostname: "chabad-il.org", hrefmatch:/hit/, params: [ { str: 'קישור התקשרות צאח ישן'}, { str: location.href, match: /hit(\d+)\./}, { func: function(){return location.hash.substr(1)} }, { func: function(){return jQuery("a[name="+location.hash.substr(1)+"]").parent().find("h1:first").text().split().reverse().join().split('\n').reverse().join(' ')} } ]
}, { hostname: /otzar770.com/, params: [ { str: 'קישור אוצר 770' }, [
{ urlparam:"nBookId"}, { str:, func: function(_){return $($($("frame[name='site']")[0].contentWindow.document) .find("frame[name='main']")[0].contentWindow.document) .find("iframe#mainArea").contents().get(0).location.href.match(/nBookId=(\d+)/)[1]} } ], [ { urlparam:"nPageNumber"}, { str:, func: function(_){return $($($($("frame[name='site']")[0].contentWindow.document) .find("frame[name='main']")[0].contentWindow.document) .find("iframe#mainArea").contents() .find("frame[name='navFrame']")[0] .contentWindow.document).find("input[name=nCurrentPage]").val()}} ], [ { urlparam:"cPartLetter"}, { str:, func: function(_){return $($($($("frame[name='site']")[0].contentWindow.document) .find("frame[name='main']")[0].contentWindow.document) .find("iframe#mainArea").contents() .find("frame[name='navFrame']")[0] .contentWindow.document).find("input[name=cPartLetter]").val()}} ],
{str:, func: function(_){
var main = $("frame[name='site']").length ? $($($("frame[name='site']")[0].contentWindow.document).find("frame[name='main']")[0].contentWindow.document): document; var title = $($(main) .find("iframe#mainArea").contents() .find("frame[name='navFrame']")[0] .contentWindow.document).find("#titleSpan").text(); rm = ["(מוגה)","(בלתי מוגה)", /^מאמרים/g, "ספרים שונים", "(Edited)","(Unedited)", 'ספרים בלה"ק']; for (x in rm) title = title.trim().replace(rm[x],); return title}, }, {func:function(_){return prompt("האדמו\"ר מחבר הספר?");}},
] }
];
var isFound = false; for (var i = 0; i < data.length; i++) { if (location.hostname.match(data[i].hostname) && (!data[i].hrefmatch || location.href.match(data[i].hrefmatch)) && (!data[i].condition || data[i].condition()) ) { var params = []; var k = 0; for (var j = 0; j < data[i].params.length; j++)
try { var curParam = (data[i].params[j] instanceof Array)?(data[i].params[j][k]):(data[i].params[j]); params[j] = ; if (typeof curParam.str != "undefined") params[j] = curParam.str; else if (typeof curParam.urlparam!= "undefined")
params[j] = getParameterByName(curParam.urlparam)||"";
else if (typeof curParam.elem != "undefined") { if (curParam.elem instanceof Array) { params[j] = $(curParam.elem[0]); for(var elemIdx = 1; elemIdx < curParam.elem.length; elemIdx++) { var func = curParam.elem[elemIdx].split(','); params[j] = params[j][func[0]](func.length>0?func[1]:null); } if (typeof(params[j]) != "string")
params[j] = params[j].html();
} else params[j] = $(curParam.elem).html(); } else if (typeof curParam.elements != "undefined") { params[j] = $(curParam.elements[0]).map(function(el){return $(this).html();}).toArray().join(curParam.elements[1]); } else if (typeof curParam.telements != "undefined") { params[j] = $(curParam.telements[0]).map(function(el){return $(this).text();}).toArray().join(curParam.telements[1]); } else if (typeof curParam.telem != "undefined") { params[j] = $(curParam.telem).first().text(); }
if (typeof curParam.match != "undefined") { if (!(curParam.match instanceof Array)) params[j] = match(params[j], curParam.match); else for (patIdx = 0; patIdx < curParam.match.length; patIdx++) { temp = match(params[j], curParam.match[patIdx]); if (temp != ) { params[j] = temp; break; } } }
if (typeof curParam.remove != "undefined")
for (var removeIdx = 0; removeIdx < curParam.remove.length; removeIdx++)
params[j] = params[j].replace(curParam.remove[removeIdx],"");
if (typeof curParam.split != "undefined") params[j] = params[j].split(curParam.split);
if (typeof curParam.func != "undefined")
{
if (!(curParam.func instanceof Array))
curParam.func = [curParam.func];
for (var funcIdx = 0; funcIdx < curParam.func.length; funcIdx++)
{
params[j] = curParam.func[funcIdx](params[j]);
}
}
if (typeof params[j] == "string") {
params[j] = jQuery.trim(unescape(params[j].replace(/ |\u202B|\u202C/gm," ").replace(/\s+/gm, ' ')) .replace("=","=") .replace(//g,'"') .replace(/(\|\|?)/gm,function(x){return "תבנית:" + x.replace(/\";}) .replace("+|+","|") ); } else if (jQuery.isArray(params[j])) { params[j] = jQuery.trim(params[j].join("|")); }
if (typeof curParam.prefix != "undefined") params[j] = curParam.prefix + params[j];
if (typeof curParam.defvalue != "undefined" && params[j] == curParam.defvalue)
params[j] = ;
if (typeof curParam.shouldnt != "undefined" && typeof params[j] == "string" && params[j].match(curParam.shouldnt)) params[j] = ;
if ((params[j] == ) && (data[i].params[j] instanceof Array) && (k < data[i].params[j].length - 1))
{
k++;
j--;
continue;
}
k = 0;
} catch(e) {console.error(e);}
var minimum = (typeof data[i].minimum != "undefined") ? (data[i].minimum) : (0);
while (params[params.length-1]=="" && params.length > minimum) //remove all last empty params params.pop();
prompt(":התבנית", 'תבנית:' + params.join(''); isFound = true; break; }
}
if (!isFound) alert("This site\\page isn't supported by the bookmarklet.");
} (function () { if (typeof(jQuery)!="undefined") window.$ = jQuery; var s=document.createElement('script'); s.setAttribute('src',"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); s.onload=wikiit; try { document.getElementsByTagName('body')[0].appendChild(s); } catch (e) { document.getElementsByTagName('head')[0].appendChild(s); }
})();