Greasy Fork

heise.de Auf einer Seite lesen

opens articles always on one page

< 脚本heise.de Auf einer Seite lesen的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发表于:2024-01-05

The current code throws a few errors, so I've updated it to get rid of them. Functionality wise nothing changed. I've updated the version to reflect the changes.

// ==UserScript==
// @name heise.de Auf einer Seite lesen
// @namespace www.heise.de
// @description opens articles always on one page
// @author Flo
// @match https://www.heise.de/*
// @version 16
// @grant none
// ==/UserScript==

var links, thisLink, i;

// Ersten "auf einer Seite lesen"-Link laden.
// Das funktioniert auch dann, wenn man auf einer Spezialseiten wie
// about:newtab auf einen Link klickt.

links = document.evaluate("//a[contains(@href, 'seite=all')]", document, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (i = 0; i < links.snapshotLength; i++) {
thisLink = links.snapshotItem(i);
if (thisLink.textContent.indexOf("Auf einer Seite lesen") >= 0) {
window.location.replace(thisLink.href);
break;
}
}

// Auf heise.de zu allen Artikel-Links den Parameter "seite=all" hinzufügen,
// damit ein Neuladen mit der obigen Methode nicht nötig ist.
// Umleitungen wie z.B. von "heise.de/meldung" zu "heise.de/newsticker/meldung"
// müssen vermieden werden, damit der Parameter erhalten bleibt.

links = document.evaluate("//a[ \
contains(@href, 'meldung') or \
contains(@href, 'tp/features') or \
contains(@href, 'make/artikel') or \
contains(@href, 'autos/artikel') or \
contains(@href, 'meinung') or \
contains(@href, '/hintergrund') or \
contains(@href, '/select') or \
contains(@href, '/ratgeber') or \
contains(@href, '/news') or \
contains(@href, '/tests') \
]", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (i = 0; i < links.snapshotLength; i++) {
thisLink = links.snapshotItem(i);
thisLink.href = thisLink.href.replace(/heise\.de\/meldung/, 'heise.de/newsticker/meldung');
thisLink.href = thisLink.href.replace(/\.html\?|\.html/, '.html?artikelseite=all&seite=all&');
}

Flo作者
§
发表于:2024-01-05

Thx for your feedback. I updated the script but left "// @namespace" unchanged. Otherwise the auto-update would not work.

Flo作者
§
发表于:2024-01-05

Thx for your feedback. I updated the script but left "// @namespace" unchanged. Otherwise the auto-update would not work.

发表回复

登录以发表回复。