Skip to content
Permalink
Browse files

Add snapshot to The Intercept.js (#1622)

This fixes #1603.
  • Loading branch information...
zuphilip committed Apr 15, 2018
1 parent 134828f commit 71d52c953a7991d15e94ad9df69c4f66ce14444b
Showing with 18 additions and 7 deletions.
  1. +18 −7 The Intercept.js
@@ -9,7 +9,7 @@
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2017-07-10 20:57:50"
"lastUpdated": "2018-04-15 16:59:35"
}

/*
@@ -36,13 +36,13 @@
***** END LICENSE BLOCK *****
*/

// attr()/text()
function attr(doc,selector,attr,index){if(index>0){var elem=doc.querySelectorAll(selector).item(index);return elem?elem.getAttribute(attr):null}var elem=doc.querySelector(selector);return elem?elem.getAttribute(attr):null}function text(doc,selector,index){if(index>0){var elem=doc.querySelectorAll(selector).item(index);return elem?elem.textContent:null}var elem=doc.querySelector(selector);return elem?elem.textContent:null}
// attr()/text() v2
function attr(docOrElem,selector,attr,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.getAttribute(attr):null;}function text(docOrElem,selector,index){var elem=index?docOrElem.querySelectorAll(selector).item(index):docOrElem.querySelector(selector);return elem?elem.textContent:null;}

function detectWeb(doc, url) {
if (/theintercept\.com\/\d{4}\/\d{2}\/\d{2}\//.test(url)) {
return "blogPost";
} else if (url.indexOf("/document/") != -1) {
} else if (url.includes("/document/")) {
return "document";
} else if (/(theintercept\.com\/search\/\?s=)|(theintercept\.com\/?$)/.test(url) && getSearchResults(doc, true) ) {
return "multiple";
@@ -58,7 +58,10 @@ function scrape(doc, url) {
item.title = ldjson.headline;
item.date = ldjson.dateCreated;
item.abstractNote = text(doc,'meta[name="description"]');
// no item.attachments: Snapshot doesn't work correctly with site
item.attachments.push({
document: doc,
title: "Snapshot"
});

// Authors
if (ldjson.authors.length) {
@@ -166,7 +169,11 @@ var testCases = [
"blogTitle": "The Intercept",
"language": "en-US",
"url": "https://theintercept.com/2017/06/05/top-secret-nsa-report-details-russian-hacking-effort-days-before-2016-election/",
"attachments": [],
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []
@@ -197,7 +204,11 @@ var testCases = [
"language": "en-US",
"shortTitle": "Manufacturing Terror",
"url": "https://theintercept.com/2015/11/19/an-fbi-informant-seduced-eric-mcdavid-into-a-bomb-plot-then-the-government-lied-about-it/",
"attachments": [],
"attachments": [
{
"title": "Snapshot"
}
],
"tags": [],
"notes": [],
"seeAlso": []

0 comments on commit 71d52c9

Please sign in to comment.
You can’t perform that action at this time.