squawkr

Add movies from IDMB to squawkr

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         squawkr
// @namespace    http://tampermonkey.net/
// @noframes
// @version      0.1
// @description  Add movies from IDMB to squawkr
// @author       Far Se
// @match        *://www.imdb.com/title/*
// @include      /.*?imdb\.com\/title\/.*?/
// @grant        none
// ==/UserScript==

    $('.summary_text').prepend(`<button style="    display: block;
    background: #e4bb24;
    font-family: Consolas;
    font-size: 15px;
    color: white;
    text-shadow: 1px 1px 1px dimgrey;
    border: none;
    padding: 5px 10px;" onclick="submitSquawkr()">Add on squawkr</button>
<script type="text/javascript">
function submitSquawkr() {
var title = text = window.getSelection().toString();
if (title === "") title = jQuery('meta[property="og:title"]')[0].content.match(/(^.*?)\\(/)[1];
$.ajax({
        url: 'https://api.themoviedb.org/3/search/movie?query=' + encodeURI(title) + '&api_key=f22e6ce68f5e5002e71c20bcba477e7d'
    })
    .done(function(d) {
        if(d.results.length)
		{
			var id = d.results[0]["id"];
			var year = d["results"][0]["release_date"].split('-')[0];
			var stuff = "<form id='squawkr_add' method='POST' action='https://squawkr.io/userAction.php'>";
			stuff = stuff + "<input name='name' value='"+title+"'>";
			stuff = stuff + "<input name='hiddenimdbID' value='"+id+"'>";
			stuff = stuff + "<input name='hiddenyear' value='"+year+"'>";
			stuff = stuff + "<input name='selQuality' value='none'>";
			stuff = stuff + "<input name='selLanguage' value=''>";
			stuff = stuff + "<input name='action_type' value='add'>";
			stuff = stuff + "<input name='id' value=''>";
			stuff = stuff + "</form>";
			$('body').append(stuff);
			$('#squawkr_add').submit();
		}else console.log(d);
    });
}</script>`);