אונטערשייד צווישן ווערסיעס פון "מעדיעוויקי:Common.js/externalsmaker.js"

אפדעיט
(אפדעיט)
(אפדעיט)
 
(11 צווישנדיגע ווערסיעס פונעם זעלבן באַניצער נישט געוויזן)
שורה 2: שורה 2:
function wikiit(event, force_popup) {
function wikiit(event, force_popup) {
window.$ = window.jQuery;
window.$ = window.jQuery;
    function hasHebrew(text) {
    if (typeof text !== 'string') {
        return false;
    }
    return /[\u0590-\u05FF]/.test(text);
    }
function dateFormat(dateArr) {
if (dateArr instanceof Array) {
var m = ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אויגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
if (dateArr.length != 3)
return '';


dateArr[1] = m[Number(dateArr[1]) - 1];
function dateFormat(dateArr, english = false) {
if (Number(dateArr[2]) <= 50)
const months = english
dateArr[2] = 20 + dateArr[2];
? ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
else if (Number(dateArr[2]) >= 50 && Number(dateArr[2]) < 100)
: ["יאנואר", "פעברואר", "מערץ", "אפריל", "מאי", "יוני", "יולי", "אויגוסט", "סעפטעמבער", "אקטאבער", "נאוועמבער", "דעצעמבער"];
dateArr[2] = 19 + dateArr[2];


if (dateArr[0].charAt(0) == '0')
if (!Array.isArray(dateArr) || dateArr.length !== 3 || !dateArr[0] || !dateArr[1] || !dateArr[2])
dateArr[0] = dateArr[0].substring(1, dateArr[0].length);
return '';


dateArr = dateArr[1] + " " + dateArr[0] + ", " + dateArr[2];
let day = String(Number(dateArr[0]));
let mIndex = Number(dateArr[1]) - 1;
if (mIndex < 0 || mIndex > 11) return '';
let month = months[mIndex];
let year = dateArr[2];
if (year.length === 2) {
year = (Number(year) <= 50 ? '20' : '19') + year;
}
}
return jQuery.trim(dateArr);
return `${month} ${day}, ${year}`;
}
}
    function dateFormatEng(dateArr) {
if (dateArr instanceof Array) {
var  m = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
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[1] + " " + dateArr[0] + ", " + dateArr[2];
function hasHebrew(str) { return /[\u0590-\u05FF]/.test(str); }
}
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 match(str, expr) { str = str ? str.match(expr) : str; return (str && str.length > 1) ? str[1] : ''; }
שורה 71: שורה 41:
.replace(/&nbsp;/g, ' ')
.replace(/&nbsp;/g, ' ')
.replace(/״/g, '"')
.replace(/״/g, '"')
.replace(/׳/g, "'")
.replace(/[׳‘’]/g, "'")
.replace(/(\n|\r)/g, ' ')
.replace(/(\n|\r)/g, ' ')
.replace(/=/g, "{{=}}")
.replace(/=/g, "{{=}}")
.replace(/''/g, '"')
.replace(/''/g, '"')
.replace(/((?<!עיתונות)\|\|?)/gm, function (x) { return "{" + "{" + x.replace(/\|/g, "!") + "}}"; }) .replace(/[\u200B\u200E\u200F\u2028\u202A\u202B\u202C\u202D\u202E]/g, '') // remove invisible Unicode control characters
.replace(/((?<!עיתונות)\|\|?)/gm, function (x) { return "{" + "{" + x.replace(/\|/g, "!") + "}}"; })
.replace(/[\u200B\u200E\u200F\u2028\u202A\u202B\u202C\u202D\u202E]/g, '') // remove invisible Unicode control characters
.replace(/ {2,}/g, ' ')
.replace(/ {2,}/g, ' ')
.replace('#google_vignette', '');
.replace('#google_vignette', '');
שורה 166: שורה 137:
{ url: 1, match: /co\.il\/((?:ency|home|headlines)\/.*?html?)/ },
{ url: 1, match: /co\.il\/((?:ency|home|headlines)\/.*?html?)/ },
{ url: 1, match: /L-(.*?),/ },
{ url: 1, match: /L-(.*?),/ },
{ url: 1, match: /co\.il\/(.*)/ } ],
{ url: 1, match: /co\.il\/(.*)/ }
],
[
[
{ url: 1, match: /co\.il\/((?:ency)\/.*?html?)/, prefix: "תאריך=", func: function(s) { return s ? 'ללא' : ''; }},
{ url: 1, match: /co\.il\/((?:ency)\/.*?html?)/, prefix: "תאריך=", func: function(s) { return s ? 'ללא' : ''; }},
שורה 500: שורה 472:
{ telem: "h1:first" },
{ telem: "h1:first" },
{ url:1, match: /makorrishon\.co\.il\/(.*?)\/?$/ },
{ url:1, match: /makorrishon\.co\.il\/(.*?)\/?$/ },
{ ldjson: { key:'datePublished'}, date:['-',[2,1,0]] }
]
]
},
},
שורה 521: שורה 494:
],
],
[
[
{ attr: ['meta[property="og:title"]', 'content'], remove:[' | ישראל היום'] },
{ attr: ['meta[property="og:title"]', 'content'], remove:[' | ישראל היום', ' | היום'] },
{ telem: ".pane-title" }
{ telem: ".pane-title" }
],
],
{ url: 1, match: /israelhayom.co.il\/(.*)$/ },
{ url: 1, match: /israelhayom.co.il\/(.*)$/ },
[
[
{ ldjson: { key:'datePublished'}, date:['-',[2,1,0]] },
{ ldjson: { raw: ['publisher', 'datePublished'] }, date:['-', '210'] },
{ ldjson: { raw: ['publisher', 'datePublished'] }, date:['-', '210'] },
{ elem: '.single-post-meta-dates > time', date: '/' },
{ elem: '.single-post-meta-dates > time', date: '/' },
שורה 550: שורה 524:
{ telem: "h1" }
{ telem: "h1" }
],
],
{ url: 1, match: /Article-(.*?).htm/ },
[
{ url: 1, match: /www\.mako\.co\.il\/(.*?)\/Article/ },
{ url: 1, match: /Article-(.*?).htm/ },
{ url: 1, match: /(liveblog-.*?).htm/ }
],
{ url: 1, match: /www\.mako\.co\.il\/(.*?)\/(Article|liveblog)/ },
[
[
{ elem: ".writerData *:last", date: '/' },
{ elem: ".writerData *:last", date: '/' },
שורה 559: שורה 536:
],
],
removeparam: {
removeparam: {
'1': [/(מערכת )?mako[א-ת ]+/]
'1': [/(מערכת )?(mako|מאקו)[א-ת ]+/, 'כתבי N12']
}
}
},
},
שורה 629: שורה 606:
},
},
{
{
hostname: "www.news1.co.il",
hostname: "news1.co.il",
params: [
params: [
{ str: 'NFC' },
{ str: 'NFC' },
שורה 724: שורה 701:
{ str: 'כיכר השבת' },
{ str: 'כיכר השבת' },
{ attr: ["meta[name='author']", "content"] },
{ attr: ["meta[name='author']", "content"] },
{ attr: ["meta[property='og:title']", "content"] },
[
{ telem: "h1" },
{ attr: ["meta[property='og:title']", "content"] }
],
[
[
{ url: 1, match: /il\/.*?\/(\d*)/ },
{ url: 1, match: /il\/.*?\/(\d*)/ },
שורה 859: שורה 839:
},
},
{
{
hostname: 'www.nli.org.il', hrefmatch: /newspapers\/bamahane/, // it's own thing and not part of the larger nli
hostname: 'www.nli.org.il', hrefmatch: /newspapers\/bamahane\//, // it's own thing and not part of the larger nli
params: [
params: [
{ str: 'במחנה' },
{ str: 'במחנה' },
שורה 865: שורה 845:
{ str: '', func: function (str) { return window.prompt("כותרת הדף", str); } }, // $('.pageblockselected').attr('title')
{ str: '', func: function (str) { return window.prompt("כותרת הדף", str); } }, // $('.pageblockselected').attr('title')
{ url: 1, match: /newspapers\/bamahane\/(\d{4}\/\d{2}\/\d{2})\// },
{ url: 1, match: /newspapers\/bamahane\/(\d{4}\/\d{2}\/\d{2})\// },
{ url: 1, match: /page\/(\d+)/ }
]
},
{
hostname: 'www.nli.org.il', hrefmatch: /newspapers\/bamahanenahal\//, // it's own thing and not part of the larger nli
params: [
{ str: 'במחנה נחל' },
{ str: '', func: function (str) { return window.prompt("שם מחבר", str!='N/A'?str:''); } },
{ str: '', func: function (str) { return window.prompt("כותרת הדף", str); } }, // $('.pageblockselected').attr('title')
{ url: 1, match: /newspapers\/bamahanenahal\/(\d{4}\/\d{2}\/\d{2})\// },
{ url: 1, match: /page\/(\d+)/ }
{ url: 1, match: /page\/(\d+)/ }
]
]
שורה 895: שורה 885:
'bustenai': 'עיתונות|bustenai',
'bustenai': 'עיתונות|bustenai',
'dav': 'דבר',
'dav': 'דבר',
'dertog': 'דער טאג (ניו יורק)',
'dhy': 'דואר היום',
'dhy': 'דואר היום',
'diedeborah' :'עיתונות|diedeborah',
'diedeborah' :'עיתונות|diedeborah',
שורה 918: שורה 909:
'hayal': 'לחייל',
'hayal': 'לחייל',
'hayomisr': 'עיתונות|hayomisr',
'hayomisr': 'עיתונות|hayomisr',
'hayomw': 'היום וורשה',
'hayomw': 'היום (ורשה)',
'hazit': 'החזית',
'hazit': 'החזית',
'hbkr': 'הבקר',
'hbkr': 'הבקר',
שורה 1,005: שורה 996:
{ url: 1, match: /\/(\d+)\/$/ }
{ url: 1, match: /\/(\d+)\/$/ }
],
],
{ telem: "span.date", match: /(\d+ ב[א-ת]+ \d+)/ }
{ attr: ['meta[property="article:published_time"]', 'content'], date: ['-', '210'] }
]
]
},
},
שורה 1,184: שורה 1,175:
{ str: 'סרוגים' },
{ str: 'סרוגים' },
[
[
{ ldjson: { key: 'author' } },
{ telem: '.post_author', match: /(.+?)\d/ },
{ telem: '.post_author', match: /(.+?)\d/ },
{ attr: ["meta[name='author']", "content"] }
{ attr: ["meta[name='author']", "content"] }
שורה 1,190: שורה 1,182:
{ url: 1, match: /\.srugim\.co\.il\/(.*)$/ },
{ url: 1, match: /\.srugim\.co\.il\/(.*)$/ },
[
[
{ ldjson: { key: 'datePublished' } },
{ attr: ["meta[property='article:published_time']", "content"], date:['-',[2,1,0]] },
{ attr: ["meta[property='article:published_time']", "content"], date:['-',[2,1,0]] },
{ telem: '.post_details', date: '.' }
{ telem: '.post_details', date: '.' }
שורה 1,371: שורה 1,364:
],
],
[
[
{ prefix:'קובץ=', attr: ["link[rel='themeData']", "href"], match: /(.*)\.files/ },
{ prefix:'קובץ=', attr: ["link[rel='themeData']", "href"], match: /^([^.]+)\.files/ },
{ prefix:'קובץ=', url: 1, func: function(s) { return s.indexOf('NetVerdicts') > -1 ? getParameterByName('fileName') : ''; }, removeifempty: true }
{ prefix:'קובץ=', url: 1, func: s => s.includes('NetVerdicts') && (f = getParameterByName('fileName')) && !f.includes('.') ? f : '', fullhref: true, removeifempty: true }
],
],
{ prefix:'סוג=', var: 'all_text', match: /\(?([^\s]+)[\s]+\d+\/\d+/m},
{ prefix:'סוג=', var: 'all_text', match: /\(?([^\s]+)[\s]+\d+\/\d+/m},
שורה 1,454: שורה 1,447:
{ url: 1, match: /il\/(.+?)\// },
{ url: 1, match: /il\/(.+?)\// },
{ telem: 'div.date > span' }
{ telem: 'div.date > span' }
]
},
{
hostname: "yuvalerel.com",
params: [
{ str: 'יובל אראל'},
{ telem: 'a.author-name' },
{ telem: 'h1.post-title ' },
{ url: 1, match: /com\/(.*)/ }
]
]
},
},
שורה 1,486: שורה 1,470:
],
],
removeparam: {
removeparam: {
'1': [ 'כתב אורח', /מאת:? / ]
'1': [ 'כתב אורח', /מאת:? /, 'מערכת Geektime' ]
}
}
},
},
שורה 1,638: שורה 1,622:
{ url: 1, match: /co\.il\/(\d+)/, dirty: true },
{ url: 1, match: /co\.il\/(\d+)/, dirty: true },
{ ldjson: { key: 'datePublished' } }
{ ldjson: { key: 'datePublished' } }
]
},
{
hostname: "academia.edu",
params: [
{ str: 'אקדמיה' },
{ ldjson: ["script[data-component-name='TopCard']", "work.authors.0.displayName"] },
{ attr: ["meta[property='og:title']", "content"] },
{ url: 1, match: /academia.edu\/(\d+)/ },
{ ldjson: ["script[data-component-name='TopCard']", "publicationName"] },
{ ldjson: ["script[data-component-name='TopCard']", "publicationYear"] }
]
]
},
},
שורה 1,646: שורה 1,641:
{ telem: "h1.firstHeading" },
{ telem: "h1.firstHeading" },
{ telem: "h1.firstHeading", func: function(data) { var match = data.match(/ - [A-Za-z].*/); return match ? data.replace(match[0], '') : false; } }
{ telem: "h1.firstHeading", func: function(data) { var match = data.match(/ - [A-Za-z].*/); return match ? data.replace(match[0], '') : false; } }
]
},
{
hostname: "academia.edu",
params: [
{ str: 'אקדמיה' },
{ attr: ["meta[name='citation_author']", "content"] },
{ attr: ["meta[property='og:title']", "content"] },
{ url: 1, match: /academia.edu\/(\d+)/ },
{ attr: ["meta[name='citation_journal_title']", "content"] },
{ attr: ["meta[name='citation_publication_date']", "content"] }
]
]
},
},
שורה 1,677: שורה 1,661:
{ str: 'תיאוריה וביקורת' },
{ str: 'תיאוריה וביקורת' },
{ telem: ".single-heading > .blacktext" },
{ telem: ".single-heading > .blacktext" },
{ telem: ".single-heading > .heading > h1", },
{ telem: ".single-heading > .heading > h1" },
{ url: 1, match: /vanleer\.org\.il\/tac_posts\/(.*)\// },
{ url: 1, match: /vanleer\.org\.il\/tac_posts\/(.*)\// },
{ telem: ".single-heading > .taxonomy", remove: [ 'גיליון' ], func: function(val) { return val.replace(' | ', ', '); } }
{ telem: ".single-heading > .taxonomy", remove: [ 'גיליון' ], func: function(val) { return val.replace(' | ', ', '); } }
שורה 1,715: שורה 1,699:
try {
try {
var curParam = data[i].params[j][k],
var curParam = data[i].params[j][k],
removed = false; params[j] = '';
removed = false;
params[j] = '';


if (typeof curParam.str != "undefined") {
if (typeof curParam.str != "undefined") {
שורה 1,887: שורה 1,872:
if (typeof curParam.shouldnt != "undefined" && typeof params[j] == "string" && params[j].match(curParam.shouldnt))
if (typeof curParam.shouldnt != "undefined" && typeof params[j] == "string" && params[j].match(curParam.shouldnt))
params[j] = '';
params[j] = '';
if (typeof curParam.combine != "undefined" && params[j]) {
params[j-1] = params[j-1] + curParam.combine + params[j];
console.log('changed', j-1, params[j-1])
params[j] = 'removeifempty';
}


if (typeof curParam.removeifempty != "undefined" && !params[j])
if (typeof curParam.removeifempty != "undefined" && !params[j])
שורה 1,892: שורה 1,883:


if (data[i].removeparam) {
if (data[i].removeparam) {
if (data[i].removeparam[j]) {
if (data[i].removeparam[j] && params[j]) {
for (var r = 0; r < data[i].removeparam[j].length; ++r) {
for (var r = 0; r < data[i].removeparam[j].length; ++r) {
var currName = params[j];
var currName = params[j];
שורה 1,958: שורה 1,949:


try {
try {
var ldojson = $('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']); });
const getldjson = () => {
var ldojson_website = [ { } ];
const ARTICLE_RE = /article/i;
if (ldojson.length == 0) {
const parsed = Array.from(document.querySelectorAll('script[type="application/ld+json"]'))
ldojson = $('script[type="application/ld+json"]').map(function(i,e) { return JSON.parse($(e).text()); }).filter(function(i,e) { return e['@graph']; });
.map(s => { try { return JSON.parse(s.textContent); } catch { return null; } })
if (ldojson.length == 1) {
.filter(Boolean);
ldojson_website = ldojson[0]['@graph'].filter(function(i,e) { return ['WebSite'].includes(i['@type']); });
const hasArticle = o => o?.['@type'] && (Array.isArray(o['@type']) ? o['@type'].some(t => ARTICLE_RE.test(t)) : ARTICLE_RE.test(o['@type']));
ldojson = ldojson[0]['@graph'].filter(function(i,e) { return ['WebPage'].includes(i['@type']); });
const direct = parsed.filter(o => !Array.isArray(o) && !o['@graph'] && hasArticle(o));
}
if (direct.length) return direct;
}
const arrayArticles = parsed.flatMap(o => Array.isArray(o) ? o : [o]).filter(o => !o['@graph'] && hasArticle(o));
if (arrayArticles.length) return arrayArticles;
return parsed.filter(o => o['@graph']).flatMap(o => o['@graph']).filter(hasArticle);
};
 
function extractArticleInfo(ldojson) {
if (!ldojson || !ldojson.length) return null;
var article = ldojson[0];
 
var ldSite = (article.publisher && article.publisher.name) || '';
var ldTitle = (article.headline || article.name || article.alternativeHeadline || '').replace(new RegExp('\\s*\\S\\s*' + ldSite + '\\s*$'), '');
if (!ldTitle) return null;
var isEnglish = !hasHebrew(ldTitle);


console.log('ldojson:', ldojson);
var date = new Date(article.datePublished || article.mainEntityOfPage?.datePublished || article.publisher?.datePublished);
if (ldojson.length == 1) {
var ldDate = (date && !isNaN(date)) ? dateFormat([''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()], isEnglish) : '';
ldojson = ldojson[0];
var date = new Date(ldojson.datePublished);
if (isNaN(date)) {
date = new Date(ldojson.publisher.datePublished);
}
var שרייבער = $.map($(ldojson.author), function(a) { return a.name; }).join(VE);
var קעפל = ldojson.name || ldojson.headline;
var זייטל = (ldojson.publisher||ldojson_website[0]).name;
var hebrewFound = hasHebrew(שרייבער) || hasHebrew(קעפל) || hasHebrew(זייטל);
var dateFormatter = hebrewFound ? dateFormat : dateFormatEng;
var authors = (Array.isArray(article.author) ? article.author : (article.author ? [article.author] : []))
var formattedDate = '';
.map(function(a){ return a?.name || (typeof a === 'string' ? a : null); }).filter(Boolean);
if (date != "Invalid Date") {
if (!authors.length && article.author)
    var dateParts = [''+date.getDate(), ''+(date.getMonth()+1), ''+date.getFullYear()];
authors.push(String(article.author).replace(new RegExp(ldSite + '$'), '').trim());
    formattedDate = dateFormatter(dateParts);  
var ldAuthor = authors.join(', ').trim();
}
 
var general = {
var general = {
    'שרייבער': שרייבער,
'קעפל': ldTitle,
    'קעפל': קעפל,
'אדרעס': location.href
    'אדרעס': location.href,
    'זייטל': זייטל,
    'דאטום': formattedDate,
};
};
if (ldSite) general['זייטל'] = ldSite;
if (ldAuthor) general['שרייבער'] = ldAuthor;
if (ldDate) general['דאטום'] = ldDate;
if (isEnglish) general['שפראך'] = 'ענגליש';
return general;
}
ldojson = getldjson();
console.log('ldojson:', ldojson);
if (ldojson.length >= 1) {
var general = extractArticleInfo(ldojson);
console.log('data', general);
console.log('data', general);