מדיה ויקי:Common.js/externalsmaker-visualeditor.js

מתוך ויקיפדיה, האנציקלופדיה החופשית

הערה: לאחר הפרסום, ייתכן שיהיה צורך לנקות את זיכרון המטמון (cache) של הדפדפן כדי להבחין בשינויים.

  • פיירפוקס / ספארי: להחזיק את המקש Shift בעת לחיצה על טעינה מחדש (Reload) או ללחוץ על צירוף המקשים Ctrl-F5 או Ctrl-R (במחשב מק: ⌘-R).
  • גוגל כרום: ללחוץ על צירוף המקשים Ctrl-Shift-R (במחשב מק: ⌘-Shift-R).
  • אינטרנט אקספלורר / אדג': להחזיק את המקש Ctrl בעת לחיצה על רענן (Refresh) או ללחוץ על צירוף המקשים Ctrl-F5.
  • אופרה: ללחוץ על Ctrl-F5.
/* This code doesn't run in wikipedia but in other sites as bookmarklet */
/* based on mediawiki:Common.js/externalsmaker.js */ 

/*Author:[[user:שמוליק]] with a lot of help from [[user:קיפודנחש]] */ 
function wikiit() {
 
	function dateFormat(dateArr)
	{
		var m = ["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"];
		if (dateArr instanceof Array)
		{
			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 jQuery.trim(dateArr);
	}
 
 function dateFormatShortHeb(dateArr)
	{
		var m = ["ינואר","פברואר","מרץ","אפריל","מאי","יוני","יולי","אוגוסט","ספטמבר","אוקטובר","נובמבר","דצמבר"];
		if (dateArr instanceof Array)
		{
			if (dateArr.length != 3)
				return '';
 
      if (dateArr[1][dateArr[1].length-1] == '\'')
      {
        for (i in m)
          if (m[i].indexOf(dateArr[1].substr(0,dateArr[1].length-1)) == 0)
          {
            dateArr[1] = m[i];
            break;
          }
      }
			
			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 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] ];
	}
 
	var ATags = [/<a .*?>/gi, /<\/a>/gi];
 
	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 data = 
  [
    {
      hostname: "www.ynet.co.il", hrefmatch:/www\.ynet\.co\.il\/yaan\/\d/i,
      params:[
        {str: "אנציקלופדיה ynet"},
        {telem: "h1"},
        {str: location.href, match: /www\.ynet\.co\.il\/yaan\/\d,\d+,L\-(\d+)/},
        {str: location.href, match: /^http:\/\/www\.ynet\.co\.il\/yaan\/\d,\d+,L\-\d+\-(.*?)\-/}
      ]
    },    
    {
     hostname: /www\.m?ynet\.co\.il/, minimum:6,
     params:[
		{str : (location.hostname.indexOf('mynet')>=0)?'mynet':'ynet'},
		[
			{elements : ['.authorHtmlCss',' ו'] },
			{telem : 'td:has(h1:first) .text14:first', func: [function(str){return (str.length<100)?str:'';}]},
			{elem : 'font.text14 span p:last', match: /^\((.*?)\)$/},
			{telem: "style+span a[href^='http://www.ynet.co.il/tags/']"}, // for ynet bug
			{telem : ".text16w" , match:/\/(.*?)$/},
			{telem : ".text16w"},
			{telem: ".art_header_footer_author span"},
		],
		[
			{telem : 'h1'},
			{telem:'.art_header_title'},
			{str : $("meta[property='og:title']").attr("content")}, //seems wrong on http://www.ynet.co.il/articles/0,7340,L-3676702,00.html
			{elem : 'head>title', match:/(?:ynet\s*-?)?([^\-]*)/},
		],
		{str : location.href, match: /L-(.*?),/},
		[
			{elem : 'td:has(h1:first) .text12g:last', match: /(\d+\.\d+\.\d+)/, split:'.', func:dateFormat},
			{elem : ".text12g + .text12g", match: /(\d+\.\d+\.\d+)/, split:'.', func:dateFormat},
			{elem : ".art_header_footer_author:last", match: /(\d+\.\d+\.\d+)/, split:'.', func:dateFormat},
		],
		{str: ''},
		{str:  location.href, match: /ynet.co.il\/[^[\/]*\/(\d+)/, defvalue: '0'},
		{str : location.href, match: /ynet.co.il\/([^[\/]*)/, defvalue: 'articles'}
     ]
	},
	{
	hostname: /^\w+\.walla\.co\.il$/, minimum:6,
	params:[
		{str : 'וואלה!'},
		[{telem : '.info .author:first', match: /^([^\|]*)/},
		 {telem : 'div.wp-0-b:first span:first', match: /מאת:(.*),/}],
		{telem : 'h1'},
		[{str : location.href, match:/item\/(\d+)/},
		 {str : location.href, match:/w=\/\d*\/(\d+)/}],
		[ {telem:'.info .date:first', match:/, (\d+ ב.*? \d+),/},{elem:["h1","parent","children","eq,2"], match:/,(.*),/, shouldnt:"online_presence"}, {telem: ".w2.txt-w:last", match:/, (\d+ ב.*? \d+),/ }],
		{str : ''},
		{str : location.href, match:/w=\/(\d*)\/\d+/},
		{str : location.href, match:/(\w+)\.walla\./, defvalue:'news'}
     ]
    },
    {
    hostname: /^\w+\.nana10\.co\.il$/i, minimum:6,
     params:[
      {str : 'נענע10'},
      {telem: '.Author:first', remove:['תרבות ובידור נענע 10','נענע 10']},
      [{telem: '#ArtTitle'},{telem: 'h1'},],
      {urlparam: 'ArticleID'},
      {elem: '.ArticleDate:first,.Date', match:/(\d+\/\d+\/\d+)/, split:'/', func:dateFormat},
      {str :''},
      {str : location.href, match:/(\w+)\.nana/i}
     ]
    },
    {
    hostname: "www.haaretz.co.il", 
     params:[
      {str : 'הארץ'},
      {telem: "#content  .author-bar li:eq(0)",  remove:['מאת ',/צילום: .*?(?:(?:[,])|(?:$))/m] },
      {telem:'h1.mainTitle'},
      {str : location.href, match:/(\d\.\d+)$/},
	  {telem: '.prsnlArticleEnvelope .author-bar li:eq(1)', match:/(\d+\.\d+\.\d+)/, split:'.' , func:dateFormat}
	  ]
    },
    {
    hostname: "www.inn.co.il", hrefmatch:/www\.inn\.co\.il.*Besheva/i,
     params:[
      {str : 'בשבע'},
	  {elem:'.Author:first', match:/<\/div>(.*)$/},
      {telem:'h3:first'},
      {str : location.href, match: /^.*\/(.*)$/},
      {telem:'.Date:first', match:/^(.*),/, split:'/' ,func:dateFormat}, //normal pages
     ]
    },
    {
    hostname: "www.inn.co.il",
     params:[
      {str : 'ערוץ7'},
      [{telem:'.ArticleAuthor h5'}, //http://www.inn.co.il/Articles/Article.aspx/7513
	   {str:'', func:[function(str){return $(".Author").contents().filter(function(){return this.nodeType===3}).text().replace(/^\s+|[,\s]+$/g, ''); }]}, //normal pages
	  ],
      {telem: (location.href.indexOf("News/Flash")<0)?'h2:first':'#divMC h3'},
      {str : location.href, match: /^.*\/(.*)$/},
      [{telem:'.Date:first, .Author', match:/(\d+\/\d+\/\d+)/, split:'/', func:dateFormat},
       {telem:'.NewsMain .Top .Right', match:/(\d+ (.*?) \d+)/, split:' ', func:dateFormatShortHeb},
       {telem:'.NewsMain .Top .Right', match:/(\d+\/\d+\/\d+)/, split:'/', func:dateFormat}], //flashnews
      {str : location.href, match: /^http\:\/\/www\.inn\.co\.il\/(\w+\/\w+)\.aspx/, defvalue:'News/News'},
     ]
    },
    {
    hostname: "www.globes.co.il",
     params:[
      {str : 'גלובס'},
      {elem:'#coteret_Writer, .g_Article_Author, #F_Author' , remove:[/<.*?>/gmi , /&nbsp;/gmi,'מאת '] },
      {elem:'#F_Title, .mainArticletitle' },
      {str : location.href, match: /=(\d+)/},
      {elem:'#coteret_Modified, #F_Modified_on, .g_Article_DateTime', match:/^(.*),/, split:'/', func:dateFormat}
     ]
    },
    {
    hostname: "www.the7eye.org.il",
     params:[
      {str : 'העין השביעית'},
      {telem:"article a[rel='tag'], article a[href*='/writer/']"},
      {telem: "h1.headline"},
      {str : location.href, match: /^http:\/\/www\.the7eye\.org\.il\/(\d+)$/},
      {telem: "article span.date", func:dateFormat, split:'.'},
      ]
    },
    {
    hostname: "www.xnet.co.il", minimum:6,
     params:[
      {str : 'xnet'},
      [{telem:'h4 .author_name_link'},{telem: '.author_name_link:visible'},{telem: '.BlogerInfo .info a:first'}],
      {telem: "h1"}, //can use ".colorTitle:first>.right" for descrition or join them to one long title
      {str : location.href, match: /L-(.*?),/},
      {telem: ".BlogInfo,.author.clearFix cite" , match: /(\d+\.\d+\.\d+)/ ,func:dateFormat, split:'.'},
      {str :''},
      {str : location.href, match: /articles\/(\d+),/, defvalue: '0'}
     ]
    }, 
    {
    hostname: "www.bhol.co.il",
     params:[
      {str : 'בחדרי חרדים'},
      {elem: '#author', match:/^\s*(.*?)\s*,/},
      {elem: '.mainTitle'},
      {str : location.href, match: /id=(\d+)/},
      {elem: '#author', match:/(\d+\/\d+\/\d+)/, split:'/', func:dateFormat}
     ]
    },
    {
    hostname: "actv.haifa.ac.il",
     params:[
      {str : 'הערוץ האקדמי'},
      {elements: ["#ctl00_ContentPlaceHolder_Content_Repeater_Humans_ctl00_HyperLink_Human_Name", ' ו']},
      {elem: '#ctl00_ContentPlaceHolder_Content_Label_Title'},
      {urlparam: 'it'},
      {elem: "#ctl00_ContentPlaceHolder_Content_Label_DateBroadcast" , remove:["תאריך הקלטה:"] ,split:'/', func:dateFormat}
     ]
    },
    {
    hostname: "www.mouse.co.il", //only "CM.articles" have a template!
     params:[
      {str : 'עכבר העיר'},
      {elem: "p.katava-info:first, p.katava-infoVer2:first", match: /מאת:(.*?)(?:$|,)/, remove:[", עכבר העיר אונליין"]},
      {telem: ".katava-box.box h1, h1"},
      {str : location.href, match: /item,(.*?),\.aspx$/},
      [{elem: "p.katava-info:first", match: /^\W+ (\d+ \W+ \d+)/},
       {elem: "p.katava-infoVer2:first", match: /^יום \W+ (\d+ \W+ \d+)/}]
     ]
    },
    {
    hostname: "www.nrg.co.il", condition: function(){return ($("h1:first").length > 0)},  minimum:8,
     params:[
      {str : 'nrg'},
      {elem: "#articleCBar span:first, .cdat.small.bold, .articleBar h4:first", match: [/<!-- ARTICLE_WRITER_START --> (.*?)<!-- ARTICLE_WRITER_END -->/ , /(.*?)&nbsp;\|/] , remove:ATags.concat(["<span>"])},
      {telem: "h1:first"},
      {str : location.href, match: /(\d+\/\d+)\.html/},
      {elem: "#articleCBar span:first, .articleBar h4:first", match: /(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat},
      {str : ''},
      {str : location.href, match: /online\/(.*?)\/ART/},
      {str : location.href, match: /ART(\d+)/}
     ]
    },
    {
    hostname: "www.nrg.co.il", condition: function(){return ($("h1:first").length == 0)},  minimum:8,
     params:[
      {str : 'nrg'},
      [
		{telem: "font.newsVitzCredit", remove:["NRG מעריב"]},
		{elem: "td.newsVitzCredit", match:/^(.*?)<br>/ ,remove:["NRG מעריב"]},
		{telem: "font.newsVitzBody:first", match:/^(.*)/ ,remove:["NRG מעריב"]}
      ],
      {telem: "#titleS1"},
      {str : location.href, match: /ART\/(.*?)\.html/},
      [
		   {telem: "font.newsVitzCredit:last, .opinionMainVitzBody", match: /(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat},
		   {telements: ["td.newsVitzCredit",""],  match: /(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat}
	    ],
      {str : ''},
      {str : location.href, match: /online\/(.*?)\/ART/},
      {str : location.href, match: /ART(\d+)/}
     ]
    },
    {
    hostname: "one.co.il",
     params:[
      {str : 'one'},
      {elem: ".f11.rtl.right, .f14b", remove:["מאת מערכת ONE","מאת "]},
      {elem: "#_ctl0_Main_ucFullArticle_lblCaption, #_ctl0_Main_ucFullArticle_lbColCaption"},
      {str: location.href, match:[/Article\/\d\d\-\d\d\/\d,\d+,\d,\d\/(\d+)/ ,/Article\/(\d+)/,/id=(\d+)/]},
      {elem: ".f10.left" ,match: /(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat}
     ]
    },
    {
    hostname: "www.israelhayom.co.il",
     params:[
      {str : 'ישראל היום'},
      {telem: ".normal14 .normal, .content li.taxonomy-term-reference-0, .views-field-name .field-content"},
      {telem: ".h2, h2.pane-title:visible:first"},
      [{urlparam: 'id'}, {str: location.href, match:/article\/(\d+)/}],
      {elem: ".newsletter_title_date, time" , split:'.',  func:dateFormat},
      {str : location.href, func:function(x){return x.indexOf('opinion')>=0?"1":"";} , def:''}
     ]
    },
   {
    hostname: "www.mako.co.il",
     params:[
      {str : 'mako'},
      [{elements: ['.writerData *:visible:first a',' ו'], shouldnt:/\d+\/\d+\/\d+/},
       {telem: 'span.katav', match:/^(.*?),?\s?$/,}],
      [{telem: ".article.clearer h1"}, {telem: "h1"}],
      {str: location.href, match:/Article-(.*?).htm/},
      {str: location.href, match:/www\.mako\.co\.il\/(.*?)\/Article/},
      [{elem:".writerData *:last", match:/(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat},
       {elem:"span.displayDate", match:/(\d+\/\d+\/\d+)/, split:'/',  func:dateFormat},
      ]
     ]
    },
   {
    hostname: /^\w+\.themarker\.com$/i,
     params:[
      {str : 'TheMarker1'},
      [{telements: [".prsnlArticleEnvelope .autorBarAnchor, .prsnlArticleEnvelope .autorBarWriters", ", "],  remove:["מאת:"]},{telem: ".author-bar li:eq(2), .h3_author",  remove:["מאת:"]}],
      {elem: "h1.mainTitle, h2"},
      {str: location.href, match:/com\/(.*?)$/},
      {telem:".author-bar li:eq(1), .h3_date", match:/(\d+\.\d+\.\d+)/, split:'.',  func:dateFormat},
      {str: location.href, match:/\/\/(.*?).themarker/i , defvalue:"www"}
     ]
    },
	{
    hostname: "www.calcalist.co.il", minimum:6,
     params:[
      {str : 'כלכליסט'},
      {telem: "h3:first"},
      {elem: "h1"},
      {str: location.href, match:/L\-(\d+)/},
      {elem:"table[style^=w] span:first", match:/(\d+\.\d+\.\d+)/m, split:'.',  func:dateFormat},
      {str:''},
      {str: location.href, match:/les\/(\d+)\,/i, defvalue:"0"}
     ]
    },
	{
    hostname: "www.news1.co.il",
     params:[
      {str : 'NFC'},
      {telem: "#ctl00_ContentMain_UcArticle1_lnkWriterName, #ctl00_ContentMain_UcArticle1_lblTopWriterName", remove:["מחלקה ראשונה"]},
      {telem: "#ctl00_ContentMain_UcArticle1_lblHead1, #ctl00_ContentMain_UcArticle1_lblSpecialTitle"},
      {str: location.href, match:/ve\/(.*?)\.html/},
      {telem:"#ctl00_ContentMain_UcArticle1_lblCreateDate", match:/(\d+\/\d+\/\d+)/m, split:'/',  func:dateFormat}
     ]
    },
    { //even this is not exactly "External Link Template"
	hostname: "aleph.nli.org.il",
     params:[
      {str : 'מאמר'},
      {telem: "#fullRecordView th:contains(מחבר):first + td", func:function(str){var strs = str.match(/^(.*?), (.*?)$/); return (strs.length==3)?(strs[2]+" "+strs[1]):str;}},
      {telem: "#fullRecordView th:contains(כותר):first + td", match:/^(.*?)\.?[\s\u202c]*$/},
      {telem: "#fullRecordView th:contains(בתוך):first + td", match:/^(.*?) \(/},
      {str:''},
      {telem: "#fullRecordView th:contains(בתוך):first + td", match:/\((.*?)\)/, func:function(yh){return yh.substring(0,yh.length-1) + '"' + yh.substr(yh.length-1);}},
      {telem: "#fullRecordView th:contains(בתוך):first + td", match:/(\d+\-\d+)/},
      {telem: "#fullRecordView th:contains(מס' מערכת):first + td", prefix: "רמבי="}
     ]
    },
    {
	hostname: "www.rollingstone.com",
     params:[
      {str : 'רולינג סטון'},
      {telem: ".author", remove:["By"]},
      [{telem: "h1"}, {telements:["h3:first, h4"," - "]}],
      {str: location.href, match:/rollingstone.com\/(.*)$/},
      {telem:".date", match:/(\w+ \d+, \d+)/m, func:[engDateParse, dateFormat]}
     ]
    },
    {
	hostname: "www.yeshiva.org.il",  hrefmatch:/\/midrash\/shiur\.asp\?id=\d+/i,
     params:[
      {str : 'אתרישיבה1'},
      {telem: ".trav", remove:["הרב"]},
      {telem: "h1"},
      {urlparam: "id"}
     ]
    },
    {
	hostname: "www.yeshiva.org.il",
     params:[
      {str : 'אתרישיבה'},
      {telem: ".trav", remove:["הרב"], prefix:"הרב="},
      {telem: "h1", prefix:"נושא="},
      {str: location.href, prefix:"קישור="}
     ]
    },
    {
	hostname: "www.sport5.co.il",
     params:[
      {str : 'ספורט 5'},
      {telem: "span#lblWriter2, #tdAuthorDateTime font", remove:["מערכת אתר ערוץ הספורט"]},
      {telem: "h1#divTopTitle"},
      [
		{str: location.href, match: /Article\.\d+\.(\d+)\.html/},
		{str: location.href, match: /docID=(\d+)/}
	  ],
      [
		{str: location.href, match: /Article\.(\d+)\.\d+\.html/},
		{str: location.href, match: /FolderID=(\d+)/}
	  ],
      {telem: "#lblDate2", split:'/',  func:dateFormat}
     ]
    },
	{
		hostname: "britishpathe.com",
		hrefmatch: /britishpathe\.com/i,
		params:[
			{str : 'British Pathe'},
			{telem: "#record-container>h1", remove:["video newsreel film"]},
			{urlparam: 'id'},
			{telem: "#researcher-stats td:eq(0)", split:'/', func:dateFormat}
		]
	},
		{
		hostname: "www.idf.il",
		params:[
			{str : 'דובר צה"ל'},
			{telem: ".inner_page span b:eq(2)"},
			{telem: "h1"},
			{str: location.href, match: /www\.idf\.il\/(\d+\-\d+)\-he\/Dover\.aspx$/i},
			{telem: ".inner_page span b:eq(1)", match:/(\d+\/\d+\/\d+)/ ,split:'/', func:dateFormat}
		]
	},
		{
		hostname: "www.kikarhashabat.co.il",
		params:[
			{str : 'כיכר השבת'},
			{telem: ".article_buttons_field:first"},
			{telem: "h1.article-title"},
			{str:  decodeURIComponent(location.href), match: /^http:\/\/www\.kikarhashabat\.co\.il\/(.*?)\.html$/i},
			{telem: ".article_buttons_field:last", match:/(\d+\.\d+\.\d+)/ ,split:'.', func:dateFormat}
		]
	},
		{
		hostname: "www.kipa.co.il",
		params:[
			{str : 'כיפה'},
			{telem: "div#by", remove:["מערכת כיפה", ", כיפה"]},
			{telem: "h1"},
			{str:  location.href, match: /^http:\/\/www\.kipa\.co\.il\/(.*?)\.html$/i},
			{telem: "div#date", match:/(\d+\/\d+\/\d+)/ ,split:'/', func:dateFormat}
		]
	},
		{
		hostname: "www.hebpsy.net",
		params:[
			{str : 'פסיכולוגיה עברית'},
			{str: $("meta[name='auhtor']").attr("content")},
			{telem: "h2.head"},
			{urlparam: 'id'},
			{telem: ".body_textarea:first > div:last", func:function(str){arr=str.match(/(\d+)..([א-ת]+)..(\d+)/);return arr[1]+" ב"+arr[2]+" "+arr[3];}} //it's not space but other character
		]
	},
		{
		hostname: "www.hayadan.org.il",
		params:[
			{str : 'הידען'},
			{telem: "a[rel='author'], span.author", remove:["מאת "]},
			{telem: "h1.entry-title, h1.single-title"},
			{str:  location.href, match: /http:\/\/www.hayadan\.org\.il\/(.*?)$/i},
			{telem: "span.meta-date, span.date"}
		]
	},
			{
		hostname: "www.hebrewbooks.org",
		params:[
			{str : 'HebrewBooksPage'},
			{telem: "span.authorname"},
			{telem: "span.sefername"},
			{urlparam: 'req'},
			{str: ""},
			{urlparam: 'pgnum'}
		]
	},
	{
		hostname: "www.izkor.gov.il", hrefmatch:/HalalKorot/i,
		params:[
			{str : 'חלל מערכות ישראל'},
			{urlparam: "id"},
		]
	},
		{
		hostname: "tchelet.org.il",
		params:[
			{str : 'תכלת'},
			{telem: "h2 + a.author"},
			{telem: "h2"},
			{urlparam: "id"},
			{telem: "#themag"}
		]
	},
		{
		hostname: "jpress.org.il",
		params:[
			{str : 'עיתונות יהודית היסטורית 2', func:function(str){
        var pub=JSON.parse($("span[data-json]").first().attr("data-json")).pub;
        var codes ={
          "BUL":{"title":"Bulletin de l'Alliance Israélite Universelle", "hasTemplate":false},
          "DAV":{"title":"דבר", "hasTemplate":true},
          "HLB":{"title":"הלבנון", "hasTemplate":false},
          "HZV":{"title":"הצבי", "hasTemplate":true},
          "ISR":{"title":"Israël", "hasTemplate":false},
          "LLB":{"title":"לה ליברט (צרפתית)", "hasTemplate":false},
          "LLR":{"title":"La Libert - Judeo-Arabic", "hasTemplate":false},
          "LRI":{"title":"L'Avenir Illustré", "hasTemplate":false},
          "MGD":{"title":"המגיד", "hasTemplate":true},
          "PLS":{"title":"PalPost", "hasTemplate":true},
          "PED":{"title":"Paix et Droit", "hasTemplate":false},
          "VDC":{"title":"La Voix des Communaut?s", "hasTemplate":false},
          "EGY":{"title":"Egyenlöség", "hasTemplate":false},
          "HSK":{"title":"השקפה", "hasTemplate":true},
          "HMZ":{"title":"המליץ", "hasTemplate":true},
          "NOR":{"title":"נער", "hasTemplate":false},
          "HZT":{"title":"חבצלת", "hasTemplate":true},
          "HZN":{"title":"הזמן", "hasTemplate":true},
          "HZF":{"title":"הצפירה", "hasTemplate":true},
          "OCC":{"title":"The Occident", "hasTemplate":false},
          "MAR":{"title":"מעריב", "hasTemplate":true},
          "HED":{"title":"הד המזרח", "hasTemplate":true},
          "HHR":{"title":"הפועל הצעיר", "hasTemplate":true},
          "HYM":{"title":"היום", "hasTemplate":true},
          "IVA":{"title":"עברי אנכי", "hasTemplate":true},
          "KMD":{"title":"קול מחזיקי הדת", "hasTemplate":true},
          "MAD":{"title":"מחזיקי הדת", "hasTemplate":true},
          "DHY":{"title":"דואר היום", "hasTemplate":true},
          "AHR":{"title":"על המשמר", "hasTemplate":true},
          "HRT":{"title":"חרות", "hasTemplate":true},
          "HYT":{"title":"היינט", "hasTemplate":true},
          "HMD":{"title":"המודיע", "hasTemplate":true},
          "MRH":{"title":"מוריה", "hasTemplate":true},
          "TAS":{"title":"מגיד מישרים", "hasTemplate":true},
          "HMI":{"title":"המזרחי", "hasTemplate":true},
          "MZP":{"title":"המצפה", "hasTemplate":true},
          "HZH":{"title":"הצופה", "hasTemplate":true},
          "HAM":{"title":"העם", "hasTemplate":true},
          "DMT":{"title":"דער מאמענט", "hasTemplate":true},
          "PLB":{"title":"PalBull", "hasTemplate":true},
          "INF":{"title":"Information Juive", "hasTemplate":false},
          "HMF":{"title":"המשקיף", "hasTemplate":true},
          "UES":{"title":"אונזער אקספרעס", "hasTemplate":false},
          "CGS":{"title":"Chicago Sentinel", "hasTemplate":false},
          "HCL":{"title":"הכרמל", "hasTemplate":true},
          "HCR":{"title":"הכרמלֹ רוסית", "hasTemplate":false},
          "HCR":{"title":"ליטערארישע בלעטער", "hasTemplate":false},
         };
        if (pub in codes && codes[pub]["hasTemplate"])
          return codes[pub]["title"];
        else if (pub in codes)
          return [str, codes[pub]["title"], pub];
         else
          return [str, JSON.parse($("span[data-json]").first().attr("data-json")).pubt, pub];
         }
      },
			{str:'', func: function(str){return window.prompt("שם מחבר","")} },
			{str:'', func: function(str){return window.prompt("כותרת הדף (מובא מגרסת הטקסט האוטומטי)",JSON.parse($("span[data-json]").first().attr("data-json")).n)} },
			{str:'', func: function(str){return JSON.parse($("span[data-json]").first().attr("data-json")).href.match(/(\d+\/\d+\/\d+)/)[1];} },
			{str:'', func: function(str){return JSON.parse($("span[data-json]").first().attr("data-json")).cid.match(/(\d+)/)[1]} },
			{str : ''},
			{str : ''},
			{str:'', defvalue:"Ar", func: function(str){return JSON.parse($("span[data-json]").first().attr("data-json")).cid.match(/^(\w+?)\d+/)[1]} },
		]
	},
	{
		hostname: "www.pc.co.il",
		params:[
			{str : 'אנשים ומחשבים'},
			{telem: "span.small a"},
			{telem:"a[rel='bookmark']"},
			{urlparam: 'p'},
			{telem: "span.date", match:/(\d+ ב[א-ת]+ \d+)/}
		]
	},
		{
		hostname: "shironet.mako.co.il", hrefmatch:/type=lyrics/,
		params:[
			{str : 'שירונט שיר'},
			{urlparam: 'wrkid'},
			{urlparam: 'prfid'},
			{telem:'.artist_song_name_txt'},
			{urlparam: 'lang', defvalue:'1'},
		]
	},
			{
		hostname: "shironet.mako.co.il", hrefmatch:/type=works/,
		params:[
			{str : 'שירונט'},
			{urlparam: 'prfid', prefix:'מספר='},
			{telem:'h1', prefix:'שם='}
		]
	},
	{
		hostname: "www.boxofficemojo.com",
		params:[
			{str : 'מוג\'ו'},
			{urlparam: 'id', match:/(.*?)\.htm/},
		]
	},
	{
		hostname: "article.yedioth.co.il",
		params:[
			{str : 'ידיעות אחרונות'},
			{telem: '#lblAuthor'},
			{telem: '#lblTitle'},
			{urlparam: 'articleid'},
			{telem: '#lblDatePublished', split:'.', func:dateFormat}
		]
	},
	{
		hostname: /www\.(thepost|maariv)\.co\.il/,
		params:[
			{str : 'מעריב השבוע'},
			{telem: 'div#divforprint a.writer'},
			{telem: 'div#divforprint h1'},
			{telem: 'div#divforprint td.date', match:/(\d+\/\d+\/\d+)/m, split:'/',  func:dateFormat},
			{prefix: 'זיהוי=', func: function(){return location.search.substr(1);}}
		]
	},
	{
		hostname: "www.onlife.co.il",
		params:[
			{str : 'onlife'},
			{telem: '.status a'},
			{telem: '.cafe_title'},
			{str:location.href, match:/www\.onlife\.co\.il\/(.*)$/},
			{telem: '.status em', match:/(\d+\.\d+\.\d+)/m, split:'.',  func:dateFormat},
		]
	}
  ];
  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(decodeURIComponent(params[j].replace(/&nbsp;|\u202B-\u202d/gm," ").replace(/\s+/gm, ' '))
                                                            .replace(/=/g,"{{=}}")
                                                            .replace(/(\|\|?)/gm,function(x){return "{{" + x.replace(/\|/g,"!") + "}}"}));
      }
      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) {}
 
 
		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 ($("#cover_bm_wiki").length > 0)
		{
			$("#cover_bm_wiki").show();
			isFound = true;
			break;
		}
		
		
		$("body").append(' \
<div style="background:#cff;position:fixed;width:100%;height:100%;top:0;left:0;opacity:0.8" \
	 id="cover_bm_wiki"> \
<div style="background:#cf0;position:absolute;left:50%;top:30%;z-index:99999" id="window_bm_wiki"> \
		<span data-ve-attributes="{&quot;typeof&quot;:&quot;mw:Transclusion&quot;}" class="ve-pasteProtect" data-ve-no-generated-contents="true" typeof="mw:Transclusion">לחץ והעתק</span> \
	<span style="background:red;position:fixed;margin:0 auto;" id="close_bm_wiki">סגור<span> \
	<br style="clear:both"> \
</div>');
	
		
		function selectText(element) {
			var doc = document, range, selection;    
			if (doc.body.createTextRange) { //ie
				range = doc.body.createTextRange();
				range.moveToElementText(element);
				range.select();
			} else if (window.getSelection) { //better browsers
				selection = window.getSelection();        
				range = doc.createRange();
				range.selectNodeContents(element);
				selection.removeAllRanges();
				selection.addRange(range);
			} else {
				alert("unsupported browser")
			}
		}
		$(".ve-pasteProtect").click(function(){
			selectText($(".ve-pasteProtect")[0]);
		});
		$("#close_bm_wiki").click(function(){
			$("#cover_bm_wiki").hide();
		});
		
		jsparams = {}
		for(q=1; q<params.length;q++)
		{
			jsparams[q.toString()]={"wt":params[q]};
		}
		
		template = {
				"parts":
					[
						{
							"template":
							{
								"target": {"wt":params[0],"href":"./תבנית:"+params[0]},
								"params": jsparams,
								"i":0
							}
						}
					]
				}
		
		// if there are more problems with JSON.stringift so http://code.google.com/p/jquery-json/
		if ([].toJSON){ //NRG
			templateS = [template].toJSON();
			templateS = templateS.substring(1,templateS.length-1);
		} else {
			templateS = JSON.stringify(template);
		}
		$("#window_bm_wiki .ve-pasteProtect").attr("data-mw", templateS);
		
		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',"https://he.wikipedia.org/w/load.php?modules=jquery&only=scripts");
	s.onload=wikiit;
	document.getElementsByTagName('body')[0].appendChild(s);
})();