// ==UserScript== // @name 豆瓣电影分级 // @namespace http://tampermonkey.net/ // @version 3.1 // @description 很喜欢IMDB APP上家长指导这个功能,下电影前可以参考一下,是否适合在投影上和家人一起看,所以给豆瓣做了这个扩展,请注意你所在的地区是否能正常访问imdb。 // @author BigKnife // @icon https://img3.doubanio.com/favicon.ico // @match *://movie.douban.com/subject/* // @grant GM_xmlhttpRequest // @connect www.imdb.com // @downloadURL none // ==/UserScript== (function () { 'use strict'; // Your code here... //https://www.imdb.com/title/tt123456/parentalguide var gimdbid; unsafeWindow.gDoc = ""; unsafeWindow.getPG = function () { let imdbel = [...document.querySelectorAll('span')].find(s => s.innerText == 'IMDb:').nextSibling; let imdbid = imdbel.textContent.trim(); gimdbid = imdbid; let info = document.querySelector('#info'); info.insertAdjacentHTML('beforeend', '
'); info.insertAdjacentHTML('beforeend', ''); let ss = "https://www.imdb.com/title/" + imdbid + "/parentalguide"; GM_xmlhttpRequest({ method: "GET", url: ss, onloadstart: function () { console.log("正在获取" + imdbid); document.querySelector("#gpg").innerText = "正在获取"; }, onload: function (response) { getPGHandleV2(response.responseText); } }) } unsafeWindow.getField = function (doc, mark) { let tmp = doc.querySelector('div[data-testid="sub-section-' + mark + '"]'); if (tmp == null) { return ""; } else { let s = tmp.previousElementSibling.firstChild.innerText; s = s.replace("None", "无"); s = s.replace("Mild", "轻微"); s = s.replace("Moderate", "中等"); s = s.replace("Severe", "严重"); let c; if (s == "无") { c = "#d0d0d0" }; if (s == "轻微") { c = "#c5e197" }; if (s == "中等") { c = "#fbca8c" }; if (s == "严重") { c = "#ffb3ad" }; return '' + s + ''; } } unsafeWindow.getDetailNum = function (doc, mark) { let tmp = doc.querySelector('div[data-testid="sub-section-' + mark + '"]'); if (tmp == null) { return 0; } else { return tmp.querySelectorAll('div[data-testid="item-id"]').length + "条评论"; } } unsafeWindow.detailHide = function () { let detail = document.querySelector('#infodetail'); if (detail != null) { detail.innerHTML = ""; } } unsafeWindow.getDetail = function (mark) { let tmp = gDoc.querySelector('div[data-testid="sub-section-' + mark + '"]'); if (tmp == null) { return 0; } else { let detail = document.querySelector('#infodetail'); let posts = tmp.querySelectorAll('div[data-testid="item-id"]'); let s = ""; for (var i = 0; i < posts.length; i++) { s += (i + 1) + "." + posts[i].textContent + "