Free Republic
Browse · Search
General/Chat
Topics · Post Article

Skip to comments.

javascript question
myself

Posted on 02/26/2018 3:18:58 AM PST by paladinkc

I've been trying to find a javascript file using grease monkey to eliminate huffington post from yahoo so it doesn't show whenever i go there for other things, the script i have calls out several different forms but it doesn't seem to work. Anyone with some actual experience more than mine that can help?


TOPICS: Computers/Internet
KEYWORDS: editing

1 posted on 02/26/2018 3:18:58 AM PST by paladinkc
[ Post Reply | Private Reply | View Replies]

To: paladinkc

here is a copy of the script i have
setInterval(removeSpam, 2000);
function removeSpam() {
var spanTags = document.getElementsByTagName(’span’);
var spamNames = [’Huffington Post’, ‘The Huffington Post’, ‘Salon’, ‘Salon.com’, ‘Vox’, ‘Vox.com’, ‘HuffPost’ ];
var found;
for (var i = 0; i < spanTags.length; i++) {
if (contains(spamNames, spanTags[i].textContent)) {
found = spanTags[i];
parentBlock = getParent(getParent(getParent(getParent(found))));
removeAllChildren(parentBlock);
}
}
}
function getParent(o) {
return o.parentNode;
}

function contains(a, obj) {
var i = a.length;
while (i—) {
if (a[i] === obj) {
return true;
}
}
return false;
}
function removeAllChildren(o) {
while (o.firstChild) {
o.removeChild(o.firstChild);


2 posted on 02/26/2018 3:21:13 AM PST by paladinkc (release the inmates and lock me up so they can pay for my vacation! Let them see how they like it!)
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc

Why the F would you EVER want to use Yahoo? It’s like Google plus a constant stream of ultra-left bloggers presented as News.


3 posted on 02/26/2018 3:24:32 AM PST by dangus (.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc

Why not block it at your router or your Hosts file? You’d see the reference on Yahoo but you’d never be able to go there.


4 posted on 02/26/2018 4:03:09 AM PST by ConservativeMind (Trump: Befuddling Democrats, Republicans, and the Media for the benefit of the US and all mankind.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc

You cannot in general terms add JavaScript to a web page coming from another server. You can inject the JavaScript by creating your own page on your file system. That page would need to have a frame to host the yahoo page. Since you JavaScript would be on the parent it could overwrite the urls in the child page.


5 posted on 02/26/2018 4:18:30 AM PST by enotheisen (CMSGT USAF Ret)
[ Post Reply | Private Reply | To 1 | View Replies]

To: ConservativeMind

I love blocking spam sites in my hosts file. Just learned... ( : >)


6 posted on 02/26/2018 4:23:03 AM PST by BTerclinger (MAGA)
[ Post Reply | Private Reply | To 4 | View Replies]

To: paladinkc

You dont need to write your own javascript. You should be able to find a browser add on (chrome, firefox..) that does that for you. Even better is to not use Yahoo at all.


7 posted on 02/26/2018 4:49:17 AM PST by libh8er
[ Post Reply | Private Reply | To 2 | View Replies]

To: enotheisen
You cannot in general terms add JavaScript to a web page coming from another server.

You can create what are called content scripts (and content styles). Content scripts have their own private JavaScript namespace but have full access to the DOM of the current page. They are basically Greasemonkey scripts, except you don't need Greasemonkey. Content scripts are a great way to consume web content on your terms, not those of the stinkin' content provider!

A typical scenario is, a website you visit often has useful content but runs an overactive ad-tech engine in the background that spins up your CPU fans and makes simple scrolling laggy. The solution? Turn off JavaScript for the site. Now everything is quiet, and the site responds instantly. Except videos don't work. Comments are not visible. In extreme cases, the site may be a blank white page.

So, to work. A little reverse engineering and content script coding can restore the essential features disabled by disabling JavaScript (JavaScript disabling does not apply to content scripts ;)), and you end up with a responsive, useful site!

Using the content script mechanism, you can also inject styles to a page. Say, there is an obnoxious navigation/ad bar stuck at the top of the screen. You can delete it, or make it scroll off normally. No JavaScript necessary. Just target it with the appropriate CSS declarations !important.

See here to get started.

Content scripts are a major part of browser extensions.

8 posted on 02/26/2018 5:04:14 AM PST by cynwoody
[ Post Reply | Private Reply | To 5 | View Replies]

To: paladinkc

"You should be using
"Misfit Garage" instead
of Grease Monkey..."


9 posted on 02/26/2018 5:39:08 AM PST by moovova
[ Post Reply | Private Reply | To 1 | View Replies]

To: dangus

Well does anyone have a right wing news feed? Sadly, I use Google.


10 posted on 02/26/2018 6:16:19 AM PST by sportutegrl
[ Post Reply | Private Reply | To 3 | View Replies]

To: sportutegrl

A right-wing NEWS FEED?

If it’s a news feed you want, maybe you’ve heard of the DRUDGE REPORT?

(OK, more libertarian than right-wing...)

Google isn’t a news feed... it’s a search engine. Now, if you want a search engine:

I don’t know enough about it to endorse it, but 4conservative.com. I use Bing; it’s politically only marginally better than Google, but at least Microsoft is more interested in selling software than heralding in our socialist-Islamofascist overlords. DuckDuckGo is the preference of most privacy freaks I know.


11 posted on 02/26/2018 6:25:55 AM PST by dangus (.)
[ Post Reply | Private Reply | To 10 | View Replies]

To: paladinkc

With the Adblock Plus browser add-on, you can block any web site just by adding the URL to Adblock Plus’ list.

IMHO, Adblock Plus is a must have. My personal list of blocked items is very long.


12 posted on 02/26/2018 6:29:27 AM PST by upchuck (Keep a sharp lookout. The best is yet to come.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc
I use uBlock Origin, and use its element picker to do cosmetic blocking on everything on Yahoo's finance page except the numbers for the stock market quotes. This prevents the screen from being filled with anti-Trump hit pieces. This might also work for your purpose.
13 posted on 02/26/2018 6:53:30 AM PST by snarkpup (Fake news is one-half of the problem. Fake education is the other half.)
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc

NoScript blocks *everything* java unless you mark it as trusted. It’s a little annoying at first, but once it’s set up it’s great.


14 posted on 02/26/2018 7:36:02 AM PST by Cats1
[ Post Reply | Private Reply | To 1 | View Replies]

To: paladinkc

search for a script to “remove fox news” and then alter it... as I am sure google will have it right up front for you.


15 posted on 02/26/2018 7:37:08 AM PST by willyd (I for one welcome our NSA overlords)
[ Post Reply | Private Reply | To 1 | View Replies]

Disclaimer: Opinions posted on Free Republic are those of the individual posters and do not necessarily represent the opinion of Free Republic or its management. All materials posted herein are protected by copyright law and the exemption for fair use of copyrighted works.

Free Republic
Browse · Search
General/Chat
Topics · Post Article

FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson