Перейти к содержанию

MediaWiki:Common.js/externalsmaker.js

Материал из Хабадпедии

Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.

  • Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
  • Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
  • Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
  • Opera: Нажмите Ctrl+F5.
function wikiit(event, force_popup) {
	window.$ = window.jQuery;

	// החלפה ל-jQuery.trim (שהוסר ב-jQuery 4)
	function trim(s) {
		return (s === null || s === undefined) ? '' : String(s).trim();
	}

	function dateFormat(dateArr) {
		if (dateArr instanceof Array) {
			var m = ["ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"];

			if (dateArr.length != 3)
				return '';

			dateArr[1] = m[Number(dateArr[1]) - 1];
			if (Number(dateArr[2]) <= 50)
				dateArr[2] = 20 + dateArr[2];
			else if (Number(dateArr[2]) >= 50 && Number(dateArr[2]) < 100)
				dateArr[2] = 19 + dateArr[2];

			if (dateArr[0].charAt(0) == '0')
				dateArr[0] = dateArr[0].substring(1, dateArr[0].length);

			dateArr = dateArr[0] + " ב" + dateArr[1] + " " + dateArr[2];
		}
		return 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.search);
		return match && decodeURIComponent(match[1].replace(/\+/gi, ' '));
	}

	var VE = ' ו',
		TODAY = 'היום',
		YESTERDAY = 'אתמול';

	// --- עזרים לחב"ד אינפו ---

	// מזהה הכתבה: המקטע המספרי האחרון בנתיב (בכתובות וידאו חדשות המזהה אינו המקטע השני)
	function infoArticleId() {
		var segs = location.pathname.split('/').filter(Boolean).filter(function (s) { return /^\d+$/.test(s); });
		return segs.length ? segs[segs.length - 1] : location.pathname.split('/')[2];
	}

	// האם הטקסט הוא תאריך עברי, למשל: א׳ בתמוז ה׳תשע״ה
	function infoIsHebrewDate(t) {
		return /\sב(?:ניסן|אייר|סיוון|סיון|תמוז|מנחם[ -]אב|אב|אלול|תשרי|מרחשוון|חשוון|כסלו|טבת|שבט|אדר)/.test(' ' + t)
			&& /ה['׳]ת/.test(t);
	}

	// כותב ותאריך מתוך .single-author. ברירת המחדל: הראשון כותב והשני תאריך.
	// כשהראשון הוא תאריך והשני לא (כתבה בלי כותב) - הראשון הוא התאריך.
	function infoAuthorDate() {
		var t1 = jQuery('html').find('.single-author > div:nth-child(1)').first().text().trim(),
			t2 = jQuery('html').find('.single-author > div:nth-child(2)').first().text().trim();
		if (infoIsHebrewDate(t1) && !infoIsHebrewDate(t2))
			return { author: t2, date: t1 };
		return { author: t1, date: t2 };
	}

	// האם הכתבה בקטגוריית וידאו (לפי פירורי הלחם: "וידאו › ילדים › ...")
	function infoIsVideo() {
		return /^וידי?או/.test(jQuery('html').find('div.banner_category').first().text().trim());
	}

	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: 'קישור לתג באינפו' },
				{ func: function() { 
                    return decodeURIComponent(location.pathname.split('/').filter(Boolean).pop()); 
                }}
			]
		},

{
			hostname: 'chabad.info', hrefmatch:/(.*)\/(.*)/,
			resultSuffix: function () { return infoIsVideo() ? ' {{וידאו}}' : ''; },
			params: [
				{ str: 'קישור חבד אינפו' },
				{ str: infoArticleId() },
				{ telem: '.div-post-ttl > h1:nth-child(1)' },
				{ func: function () { return infoAuthorDate().author; } },
				{ func: function () { return infoAuthorDate().date; } }
			]
		},
   

		{
			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+\.htm/ },
				{ str:  location.href, match: /hageula.com\/[^/]+\/[^/]+\/(\d+)\.htm/ },
				{ 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+\.htm/, defvalue:'news'}
			]
		},
{
			hostname: 'col.org.il',
			params: [
				{ str: 'קישור חבד און ליין' },
				{ str: (location.pathname.match(/\/(\d+)\/?/) || [])[1] || (location.href.match(/_(\d+)\.html/) || [])[1] || getParameterByName('artID') || '' },
				{ str: document.title.replace(/ - col חב"ד און ליין/gi, '').replace(/`/g, "'").replace(/\s+{{\!}}\s+/g, " {{!}} ").trim() },
				{ telem: '.writer_name' },
				{ telem: '.date:eq(1)', func: function(dateStr) {
					var cleanDate = dateStr.replace(/^יום\s+/i, '').replace(/\s+/g, ' ').trim();
					return cleanDate.replace(/(\d{2}\.\d{2}\.\d{4})/, '($1)');
				}}
			]
		},
		{
			hostname: 'shturem.net',
			params: [
				{ str: 'קישור שטורעם' },
				{ urlparam:'id' },
				{ urlparam:'section' },
				{ telem: '.artTitle' },
				{ telem: '.artReporter' },
				{ telem: '.artDate' }
			]
		},
	{
			hostname: 'www.chabad.org.il', hrefmatch: /Magazines/,
			params: [
				{ func: function() {
					// סורק רק את פירורי הלחם (קישורים שכוללים פרמטרים של הכתבה/קטגוריה)
					var breadcrumbText = "";
					$("a.navigationTab").each(function() {
						var href = $(this).attr("href") || "";
						if (href.indexOf("CategoryID") > -1 || href.indexOf("Article") > -1) {
							breadcrumbText += " " + $(this).text();
						}
					});
					
					// בודק אם "שיחת השבוע" מופיע ספציפית בפתיל הניווט של הכתבה
					if (breadcrumbText.indexOf("שיחת השבוע") > -1) {
						return 'קישור שיחת השבוע צאח';
					}
					return 'קישור התקשרות צאח';
				}},
				{ urlparam: 'CategoryID' },
				{ urlparam: 'ArticleID' },
				{ func: function() {
					// מוצא את מספר הגיליון מתוך פירורי הלחם
					var issueNum = "";
					$("a.navigationTab").each(function() {
						var txt = $(this).text();
						var href = $(this).attr("href") || "";
						var match = txt.match(/(\d+)/);
						if (match && (txt.indexOf("גיליון") > -1 || href.indexOf("CategoryID") > -1)) {
							issueNum = match[1];
						}
					});
					return issueNum;
				}},
				{ 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: "hebrewbooks.org", hrefmatch: /org\/\d/,
			params: [
				{ str: 'היברובוקס' },
				{ telem: "span.authorname" },
				{ telem: "span.sefername" },
				[
					{ urlparam: 'req' },
					{ url: 1, match: /hebrewbooks\.org\/(\d+)$/i }
				],
				{ prefix: "{{כ}}", telements: ["#cpMstr_lblHebPlace:first, #cpMstr_lblHebDate:first", " "] },
				{ urlparam: 'pgnum', prefix: 'עמוד דיגיטלי=' }
			]
		},
		{
			hostname: "hebrewbooks.org", hrefmatch: /pgnum/,
			params: [
				{ str: 'היברובוקס' },
				{ telem: "span.authorname" },
				{ telem: "span.sefername", remove: "-----" },
				[
					{ urlparam: 'req' },
					{ url: 1, match: /hebrewbooks\.org\/(\d+)$/i }
				],
				{ telements: ["#cpMstr_lblHebPlace:first, #cpMstr_lblHebDate:first", " "] },
				{ urlparam: 'pgnum', prefix: 'עמוד דיגיטלי=' }
			]
		},
		{
						hostname: 'otzar.org',
			params: [
				{ str: 'אוצר החכמה' },
				[
					{ urlparam: 'book', func: function (bookid) {
						if (!bookid) try{ bookid = $('#book-iframe').attr('src').match(/book=(\d+)/)[1]; } catch(e) {}
						if (bookid && location.hostname == 'tablet.otzar.org') {
							window.detail_data =
								JSON.parse($.post({ url: '//tablet.otzar.org/he/php/detailBook.php', async: false,
									data:'{"ParamQuery":"{\\"NUMBOOK\\":\\"'+bookid+'\\",\\"USERDATAID\\":0}","sqlFile":"selectSubOfBook"}' }
								).responseText).arr[0];
						} else if (window.booknameS && window.authorS) {
							bookid = bookid || window.bookid;
							window.detail_data = {
								AUTHOR: window.authorS,
								FULLNAME: window.booknameS,
								bookid: bookid
							};
						} else {
							bookid = bookid || window.bookid;
							var parts = $('title').text().replace('  - אוצר החכמה','').split('/'); // new pages (april 2022)
							if (parts.length == 1) {
								parts = document.querySelector('div.item-tab-con.active .tab-title').textContent.split('/'); // old pages (april 2022)
							}
							window.detail_data = {
								AUTHOR: parts[1],
								FULLNAME: parts[0],
								YEAR: parts[2],
								PrintedP_AND_YEAR: parts[0].split('-')[1],
								bookid: bookid
							};
						}
					} },
					{ var: ['detail_data', 'AUTHOR'] }
				],
				{ var: ['detail_data','FULLNAME'] },
				[
					{ var: ['detail_data','bookid'] },
					{ url: 1, match: /(?:book|b)\/(\d+)\//, fullhref: true }
				],
				[
					{ var: ['detail_data', 'PrintedP_AND_YEAR'] },
					{ func: function () {
						return [
							window.detail_data['PrintedP'].match(/[\u0590-\u05FF ]+/)[0],
							window.detail_data['YEAR']
						].join(' ');
					} },
					{ var: ['detail_data', 'YEAR'] }
				],
				{ str: '' },
				[
					{ attr: ['input[data-v-232cab64]', 'value'], prefix: 'עמוד דיגיטלי=' },
					{ attr: ["ab", "value"], match: /^([^ ]*) /, prefix: 'עמוד דיגיטלי=' },
					{ elem: ["#ab", "val"], prefix: 'עמוד דיגיטלי=', match: /^(\d+) / },
					{ urlparam: 'pagenum', prefix: 'עמוד דיגיטלי=' },
					{ attr: ['.nav-active', 'position'], prefix: 'עמוד דיגיטלי='}
				]
			]
		},
		{
      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: 'machon-halacha.co.il',
			params: [
				{ str: 'קישור מכון הלכה' },
				{ str: location.pathname },
				{ func: function() {
					// 1. שליפה נקייה מתוך תגית H1 בדף
					var title = $("h1").first().text().trim();
					
					// 2. גיבוי: ניקוי הקידומת או הסיומת מתוך document.title
					if (!title) {
						title = document.title
							.replace(/^מכון הלכה חב"ד\s*[-|–:]\s*/gi, '')
							.replace(/\s*[-|–:]\s*מכון הלכה חב"ד.*/gi, '')
							.trim();
					}
					return title;
				}},
				{ func: function() {
					// שליפת שם הרב מתוך אלמנטים בדף או סריקת הטקסט
					var rabbi = $('[class*="rabbi"], [class*="author"], .qa-author, .author-name').first().text().trim();
					
					if (!rabbi || rabbi.length > 40) {
						var bodyText = $("body").text();
						var match = bodyText.match(/(?:משיב|נענה על ידי|השיב|מאת|הרב המשיב):?\s*(הרב\s+[\u0590-\u05FF"'\-]+\s+[\u0590-\u05FF"'\-]+)/) ||
						            bodyText.match(/(הרב\s+[\u0590-\u05FF"'\-]+\s+[\u0590-\u05FF"'\-]+)/);
						rabbi = match ? match[1].trim() : '';
					}
					return rabbi;
				}}
			]
		},
		{
			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("האדמו\"ר מחבר הספר?");}},
			]
		} 
	];
	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 = [];
			for (var j = 0; j < data[i].params.length; j++) {
				if (!(data[i].params[j] instanceof Array)) {
					data[i].params[j] = [data[i].params[j]];
				}
				for (var k=0; k < data[i].params[j].length; k++) {
					try {
						var curParam = data[i].params[j][k];
						params[j] = '';
						if (typeof curParam.str != "undefined") {
							params[j] = curParam.str;
						} else if (typeof curParam.ldjson != "undefined") {
							var ldjson = null
							var ldjsons = $('script[type="application/ld+json"]').map(function(i,e){return JSON.parse($(e).text())})
							if (typeof curParam.ldjson.n != "undefined"){
								ldjson = ldjsons[curParam.ldjson.n]
							} else {
								var filteredLdjson = ldjsons.filter(function(i,e){return (curParam.ldjson.type?[curParam.ldjson.type]:['NewsArticle','Article']).includes(e['@type'])})
								if (filteredLdjson.length == 1){
									ldjson = filteredLdjson[0]
								} else {
									console.error("more/less than single ldjson", filteredLdjson)
									if (window.old$) {window.$ = window.old$;}
									return
								}
							}
							if (curParam.ldjson.key == "datePublished"){
								params[j] = ldjson.datePublished;
								if (!curParam.date){
									curParam.date = ['-', '210']
								}
							} else if (curParam.ldjson.key == "author"){
								params[j] =
									$.map($(ldjson.author), function(a){return a.name})
									.join(VE)
							} else if (typeof curParam.ldjson.raw != "undefined"){
								if (!(curParam.ldjson.raw instanceof Array)) {
									curParam.ldjson.raw = [curParam.ldjson.raw]
								}
								params[j] = ldjson
								for (var t=0; t < curParam.ldjson.raw.length; t++){
									console.log('curParam.ldjson.raw[t]', curParam.ldjson.raw[t])
									params[j] = params[j][curParam.ldjson.raw[t]];
								}
							}
						} else if (typeof curParam.url != "undefined") {
							params[j] = location.href;
							if (curParam.url == 'decodeURIComponent')
								params[j] = decodeURIComponent(params[j])
							else if (curParam.url == 'decodeURI')
								params[j] = decodeURI(params[j])
						} else if (typeof curParam.attr != "undefined"){
							params[j] = jQuery('html').find(curParam.attr[0]).attr(curParam.attr[1]);
						} else if (typeof curParam.var != "undefined") {
							if (!(curParam.var instanceof Array))
								curParam.var = [curParam.var]
							params[j] = window;
							for (var vi=0; vi < curParam.var.length; vi++) {
								params[j] = params[j][curParam.var[vi]]
								// console.log(vi, params[j], curParam.var[vi])
								if (!params[j])
									break
							}
							if (params[j] == window)
								params[j] = undefined
						}
						else if (typeof curParam.urlparam != "undefined") {
							params[j] = getParameterByName(curParam.urlparam) || "";
						} else if (typeof curParam.elem != "undefined") {
							if (curParam.elem instanceof Array) {
								params[j] = jQuery('html').find(curParam.elem[0]);
								for (var elemIdx = 1; elemIdx < curParam.elem.length; elemIdx++) {
									var func = curParam.elem[elemIdx].split(',');
									params[j] = (func.length > 1) ? params[j][func[0]](func[1]) : params[j] = params[j][func[0]]();
								}
								if (typeof (params[j]) != "string")
									params[j] = params[j].html();
							}
							else
								params[j] = jQuery('html').find(curParam.elem).html();
						}
						else if (typeof curParam.first_text_node != "undefined"){
							params[j] = jQuery('html').find(curParam.first_text_node).contents().filter(function () { return this.nodeType === 3 }).text()
						} else if (typeof curParam.elements != "undefined" || (typeof curParam.telements != "undefined")) {
							var sep;
							if (typeof curParam.elements != "undefined"){
								params[j] = jQuery('html').find(curParam.elements[0]).map(function (el) { return $(this).html(); }).toArray()
								sep = curParam.elements[1];
							}
							if (typeof curParam.telements != "undefined"){
								params[j] = jQuery('html').find(curParam.telements[0]).map(function (el) { return $(this).text(); }).toArray();
								sep = curParam.telements[1];
							}
							if (sep != VE){ // hack for VE
								params[j] = params[j].join(sep);
							} else {
								if (params[j].length > 2){
									params[j] = [params[j].slice(0,-1).join(', '), params[j].slice(-1)].join(sep);
								} else {
									params[j] = params[j].join(sep);
								}
							}
						}
						else if (typeof curParam.telem != "undefined") {
							params[j] = jQuery('html').find(curParam.telem).first().text().trim();
						}

						if (typeof curParam.match != "undefined") {
							if (!(curParam.match instanceof Array))
								params[j] = match(params[j], curParam.match);
							else for (var patIdx = 0; patIdx < curParam.match.length; patIdx++) {
								var 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 curParam.date != "undefined") {
							if (!(curParam.date instanceof Array))
								curParam.date = [curParam.date, [0,1,2]];
							var sep = curParam.date[0].replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
							params[j] = match(params[j], RegExp(('(\\d+' + sep + '\\d+' + sep + '\\d+)')))
							if (params[j]){
								params[j] = params[j].split(curParam.date[0]);
								params[j] = [params[j][curParam.date[1][0]], params[j][curParam.date[1][1]], params[j][curParam.date[1][2]]]
								params[j] = dateFormat(params[j]);
							}
						}
						if (typeof curParam.stringDate != "undefined") {
							if (params[j]) {
								var today = new Date(),
									dd = (today.getDate() - (params[j] == YESTERDAY ? 1 : 0)).toString(),
									mm = (today.getMonth() + 1).toString(),
									yy = today.getFullYear().toString().slice(-2);
								params[j] = dateFormat([dd, mm, yy]);
							}
						}
						if (typeof params[j] == "string") {
							try {
								params[j] = trim(decodeURIComponent(params[j]))
							} catch (e) {
								console.error(e)
							}
							params[j] = params[j]
								.replace(/&nbsp;|[\u202A-\u202E]/g, " ")
								.replace(/\s+/g, ' ')
								.replace(/=/g, "{{=}}")
								.replace(/(\|\|?)/gm, function(x) { return "{{" + x.replace(/\|/g, "!") + "}}" })
								.replace(/(\|\|?)/gm, function(x) { return "{{" + x.replace(/\|/g, "!") + "}}" });
						}
						else if (Array.isArray(params[j])) {
							params[j] = trim(params[j].join("|"));
						}

						if (params[j] && 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] != '') && (params[j] != undefined)) {
							console.log('found', j, params[j])
							break;
						}
						console.log('not found', j, curParam)
					}
					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();

			if (window.popup_template_canceled && !force_popup){
				console.log('popup_template_canceled');
			} else {
				var result = (typeof data[i].resultPrefix == "function" ? data[i].resultPrefix() : '') + '{{' + params.join('|') + '}}' + (typeof data[i].resultSuffix == "function" ? data[i].resultSuffix() : '')
				if (prompt("לחיצה על אישור תעתיק את התבנית:", result) != null){
					$('<input>').val(result).appendTo('body').select();document.execCommand('copy');
				}
				window.popup_template_canceled = false;
				if (window.old$) {window.$ = window.old$;}
			}
			return
		}
	}

	try {
		var ldjson = $('script[type="application/ld+json"]').map(function(i,e){return JSON.parse($(e).text())}).filter(function(i,e){return ['NewsArticle', 'Article', 'article'].includes(e['@type'])})
		var ldjson_website = [{}]
		//saw on 0404 and hwzone
		if (ldjson.length == 0){
			ldjson = $('script[type="application/ld+json"]').map(function(i,e){return JSON.parse($(e).text())}).filter(function(i,e){return e['@graph']})
			if (ldjson.length == 1){
				ldjson_website = ldjson[0]['@graph'].filter(function(i,e){return ['WebSite'].includes(i['@type'])})
				ldjson = ldjson[0]['@graph'].filter(function(i,e){return ['WebPage'].includes(i['@type'])})
			}
		}

		console.log('ldjson:', ldjson)
		if (ldjson.length == 1){
			ldjson = ldjson[0]
			var date = new Date(ldjson.datePublished)
			if (isNaN(date)){
				// for example in Israel Hayom
				date = new Date(ldjson.publisher.datePublished)
			}
			console.log('date', date)
			var general = {
				'הכותב': $.map($(ldjson.author), function(a){return a.name}).join(VE),
				'כותרת': ldjson.name || ldjson.headline,
				'אתר': (ldjson.publisher||ldjson_website[0]).name,
				'תאריך': dateFormat([''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()]),
				'כתובת': location.href
			}
			var result = '{{קישור כללי|'+$.map(general, function(v,k){
				return k + '=' +  trim(decodeURIComponent($('<a />').html(v).text()))
					.replace(/&nbsp;|[\u202A-\u202E]/g, " ")
					.replace(/\s+/g, ' ')
					.replace(/=/g, "{{=}}")
					.replace(/''/g, '"')
					.replace(/(\|\|?)/gm, function (x) { return "{{" + x.replace(/\|/g, "!") + "}}" })
					.replace(/(\|\|?)/gm, function (x) { return "{{" + x.replace(/\|/g, "!") + "}}" })
			}).join('|') + '}}'
			if (prompt("לחיצה על אישור תעתיק את התבנית:", result) != null){
				$('<input>').val(result).appendTo('body').select();document.execCommand('copy');
			}
			if (window.old$) {window.$ = window.old$;}
			return
		}
	} catch (e){
		console.error('failed to create general link', e)
	}

	alert("אתר או עמוד זה אינו נתמך על ידי הבוקמרקלט.");
	if (window.old$) {window.$ = window.old$;}
}
(function () {
	if (typeof (jQuery) == "undefined"){
		if (typeof ($) != "undefined"){
			window.old$ = window.$;
			console.log('store old dollar')
		}
		var s = document.createElement('script');
		s.setAttribute('src', "https://he.wikipedia.org/w/load.php?modules=jquery&only=scripts");
		s.onload = wikiit;
		document.getElementsByTagName('body')[0].appendChild(s);
	} else {
		wikiit()
	}
})();

Сообщить об ошибке на этой странице