gaoqing.la 關聯豆瓣

try to take over the world!

当前为 2019-05-13 提交的版本,查看 最新版本

// ==UserScript==
// @name         gaoqing.la 關聯豆瓣
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.douban.com/search*
// @match        http://gaoqing.la/*
// @grant        GM_setValue
// @grant        GM_getValue
// @require      https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js
// ==/UserScript==

(function() {
    'use strict';

    console.log('gaoqing');
	//var $ = unsafeWindow.jQuery;

    $(function(){
       //  try {
            if (/www\.douban\.com/.test(location.href)) {
              if (location.hash && location.hash.length > 0) {
                if (location.hash.slice(1) == "autoselect") {
                  $(".result-list .result .title h3").each(function () {
                    if (
                      $(this)
                        .find("span")
                        .eq(0)
                        .text() == "[电影]"
                    ) {
                      if (
                        $(this)
                          .find("a")
                          .eq(0)
                          .attr("href") != null
                      ) {
                        $(location).prop(
                          "href",
                          $(this)
                            .find("a")
                            .eq(0)
                            .attr("href")
                        );
                        return false;
                      }
                    }
                  });
                }
              }
            } else {
                _subGaoqingReplace();
            }
//           } catch (err) {
//             console.log("gaoqing replace Error:" + err.message);
//           }


           function _subGaoqingReplace() {
      $("span,p")
        .not("script")
        .not("a")
        .each(function () {
          var valuetext = $(this).text();
          var n1 = valuetext.indexOf("片  名");
          if (n1 > 0) {
            var name = null;
            if (this.nodeName == "P") {
              var n2 = valuetext.indexOf("年  代");
              name = valuetext.substr(n1 + 4, n2 - n1 - 4 - 1);
            } else {
              name = valuetext.substr(n1 + 4);
            }
            name = $.trim(name).replace("\n", "");
            if (name != null) {
              console.log("gaoqingreplace:" + name);
              var h = $(this)
                .html()
                .replace(
                  name,
                  "<a href='https://www.douban.com/search?q=" +
                  name +
                  "#autoselect' target='_blank' style='font-weight:bold;'><font color='#0000FF'>" +
                  name +
                  "</font></a>"
                );


              console.log(h);
              $(this).before(h);
              $(this).remove();
              return false;
            }
          }
        });
    };




    });

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址