低端豆瓣

加入可能的低端影视链接

目前为 2023-05-27 提交的版本。查看 最新版本

// ==UserScript==
// @name           低端豆瓣
// @namespace      https://github.com/mefengl
// @author         mefengl
// @version        0.2.0
// @description    加入可能的低端影视链接
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ddys.art
// @match          https://movie.douban.com/subject/*
// @grant          GM_xmlhttpRequest
// @run-at         document-end
// @license        MIT
// ==/UserScript==

(function() {
    'use strict';

    const id = window.location.href.match(/subject\/(\d+)/)[1];
    const asideDiv = document.querySelector('.aside');
    const baseURL = "https://ddys.art/?s=";

    GM_xmlhttpRequest({
        method: "GET",
        url: baseURL + encodeURIComponent(id),
        onload: (response) => {
            const parser = new DOMParser();
            const doc = parser.parseFromString(response.responseText, "text/html");
            const postTitles = doc.querySelectorAll(".post-title > a");

            postTitles.forEach((postTitle) => {
                postTitle.style.cssText = "display:block; margin-bottom:10px; background-color:#ddd; padding:5px; text-align:center; cursor:pointer; border-radius:5px; color:#3a8fb7";
                postTitle.target = "_blank";

                const sourceLabel = document.createElement('small');
                sourceLabel.textContent = " (from 低端影视)";
                sourceLabel.style.cssText = "color:#666; margin-left:5px";
                postTitle.appendChild(sourceLabel);

                asideDiv.insertBefore(postTitle, asideDiv.firstChild);
            });
        }
    });
})();