Skip to content
This repository has been archived by the owner on Mar 28, 2021. It is now read-only.

Commit

Permalink
Expanded functionality! Looking pretty great!
Browse files Browse the repository at this point in the history
  • Loading branch information
vonbearshark committed Sep 19, 2015
1 parent 1f74055 commit 75b86b6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ Top 10 Reasons Only 90's Kids Won't Even Believe What This Extension Does!

Build using professor Bill Laboon's Infinite Viral: [source](https://github.com/laboon/viral_gen), [site](http://infiniteviral.com/)

(Currently only works on the New York Times...)
Screens:

Screen:
This is your new existence:

![NYT Screenshot](/infiniteviralnytscreen.png?raw=true "New York Times")
![LA Times Screenshot](/infinitevirallatscreen.png?raw=true "LA Times")

It even works on Buzzfeed! (Admittedly, this was hard to test for.)

![Buzzfeed Screenshot](/infiniteviralbfscreen.png?raw=true "Buzzfeed")

---

Install
Download and install [chrome store link](https://chrome.google.com/webstore/detail/infinite-viral/gejghfapdoblkdeghocaggoalocccacg "on the chrome store")

---
46 changes: 27 additions & 19 deletions infiniteViral.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,25 +847,33 @@
}

//alright, generate the headlines!
//get a headline with: generate();
//find the title on the page
//this is tricky, because their's no standard headlines
//so look through all likely element classes for keywords
//right now it assumes a pretty semantic DOM
(function() {
//get a headline with: var headline = generate();
//find the title on the page
//this is trick, because their's no standard for defining
// what this looks like
//so... look through all classes and elastic search?
//TODO: hard-coded for now...
//if there is a <a>, go a level deep, if not just find the <h-tag> (no always h1...)
//check if the thing with the class is an h1 or div... (only find h1s?) only find a tags? Then go by news orgs?
var headings = Array.prototype.slice.call(document.querySelectorAll('.story-heading'));

//var nodes = Array.prototype.slice.call(master.getElementsByTagName("*"), 0);
for(var i = 0; i < headings.length; i ++) {
if(headings[i].childNodes && headings[i].childNodes[0].tagName === 'A') {
headings[i].childNodes[0].textContent = generate();
}
else {
headings[i].textContent = generate();
}
};
var headings = Array.prototype.slice.call(document.querySelectorAll('h1, h2, h3, h4, h5, h6, a')).map(
function(heading) {
if(heading.className.toLowerCase().indexOf('story') > -1 ||
heading.className.toLowerCase().indexOf('headline') > -1 ||
heading.className.toLowerCase().indexOf('title') > -1 ||
heading.className.toLowerCase().indexOf('lede') > -1) {

if(heading.tagName === 'A' && /\S/.test(heading.innerText)) {
heading.innerText = generate();
}
else if (heading.tagName !== 'A'){
//TODO: Assumes first child link is the article heading
var links = Array.prototype.slice.call(heading.querySelectorAll('a'));
if(links.length > 0) {
links[0].innerText = generate();
}
else {
heading.innerText = generate();
}
}
}
});
})();

Binary file added infiniteviralbfscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added infinitevirallatscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"name": "Infinite Viral",
"description": "Viral news all the time.",
"version": "1.0",
"version": "1.1.0",

"browser_action": {
"default_icon": "icon.png",
Expand Down

0 comments on commit 75b86b6

Please sign in to comment.